Question: mport java.util.Scanner; public class DivisionMistakeCaught { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System .

mport java.util.Scanner;
public class DivisionMistakeCaught {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
int numerator, denominator, result;
System.out.print("Enter numerator >>");
numerator = input.nextInt();
System.out.print("Enter denominator >>");
denominator = input.nextInt();
try {
result = numerator / denominator;
System.out.println(Worked fine);
return;
}
catch (ArithmeticException mistake){
System.out.println("Arithmetic exception was thrown and caught");
}
System.out.println("End of program");
}
}
If we enter a non-zero denominator What will be the output of this code?
a. This code will print Worked fine and then End of program.
b. This code will print Arithmetic exception was thrown and caught first and then End of program.
c. This code will only print End of program.
d. This code will only print Worked fine.

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 Programming Questions!