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 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 istringargs) calculator ob- new calculator obdivide obs.display_namelength(); 1 > class calculator String name - null int num: int num2; public calculator) Scanner input = new Scanner(System.in); System.out.println("Enter the first number); this.num Input.nextInt (); System.out.println("Enter the second number: this.numz - input.nextInt(); ) public void dividei System.out.println (numl 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(Stringil args) try int acc - 100, 101, 102, 103, 104, 105 double balanced) - 2000, 1500, 900, 1560, 1765.50 Syatem.out.println("Account Nolt" + "Balance for (int - 0:1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
