Question: question 2 Course code : Object Oriented Programming I need this question answer with in 1 hour. using java language Question 2 [3 + 5)
question 2
Course code : Object Oriented Programming
I need this question answer with in 1 hour. using java language

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 numl; 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(numl / num2); 1 public void display_namelength() [ System.out.println(name.length()); // name object can be null B. Complete the following code: class Mainclass! public static void main(String[] args) { try int acc[] - (100, 101, 102, 103, 104, 105); double balance[] = {2000, 1500, 900, 1560, 1765.50); System.out.println("Account Nolt" + "Balance\t"); for (int i = 0; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
