Question: Scanner input = new Scanner ( System . in ) ; int numerator, denominator, result; try { System.out.print ( Enter numerator > >

Scanner input = new Scanner(System.in);
int numerator, denominator, result;
try
{
System.out.print("Enter numerator >>");
numerator = input.nextInt();
System.out.print("Enter denominator >>");
denominator = input.nextInt();
result = numerator / denominator;
}
catch(Exception mistake)
{
System.out.println(mistake.getMessage());
}
catch(ArithmeticException mistake)
{
System.out.println(mistake.getMessage());
}
catch(InputMismatchException mistake)
{
System.out.println("Wrong data type");
}
System.out.println("End of program");
If the user enters 0 as the denominator, the division statement throws an exception. Which of these exceptions will be executed?
a. ArithmeticException
b. InputMismatchException
c. Exception
d. exception java.lang.ArithmeticException has already been caught

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!