Question: Examine the following program. Show the output for the attempted input below: import java.util.InputMismatchException; import java.util.Scanner; public class MainApp{ public static void main (String []
Examine the following program. Show the output for the attempted input below:
import java.util.InputMismatchException;
import java.util.Scanner;
public class MainApp{
public static void main (String [] args) {
int x,y;
int result;
Scanner in = new Scanner (System.in);
try {
x = in.nextInt();
y = in.nextInt();
System.out.println ("BLUE");
result = x / y;
System.out,println(result);
}
catch (ArithmeticException e) {
System.out.println("Error RED");
}
catch (InputMismatchException e){
System.out.println("Error BLACK");
}
finally{
System.out.println("GREEN");
} } }
a. 4 2
b. 4.5 2
c. 0 4
d. 4 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
