Question: Question 2 [3 + 5) A. Rewrite the given code such that it handles exceptions and the message Exception handled successfully should be displayed whether

 Question 2 [3 + 5) A. Rewrite the given code such

Question 2 [3 + 5) A. Rewrite the given code such that it handles exceptions and the message "Exception handled successfully" should be displayed whether an exception occurs or not for both divide() and display_namelength() methods. You can only change inside the main function. public class ExceptionTest public static void main(String[] args) { calculator obj = new calculator(); obj.divide(): obj.display_namelength(); class calculator String name - null; int numi; int num2; public calculator() { Scanner input - new Scanner (System.in); System.out.println("Enter the first number"); this.numl = input.nextInt (); System.out.println("Enter the second number"); this.num2 - input.nextInt (); public void divide() System.out.println(numi / num2); } public void display_namelength() { System.out.println (name.length(); // name object can be null 1 B. Complete the following code: class MainClass public static void main(Stringl] args) try int acc[] - (100, 101, 102, 103, 104, 105); double balanced) - 2000, 1500, 900, 1560, 1765.50); System.out.println("Account No\t" + "Balance\t"); for (int i = 0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!