Question: This question tests your ability to work with Exceptions in Java. Consider the following program: public class ExceptionExample { public static void main ( String

This question tests your ability to work with Exceptions in Java.
Consider the following program:
public class ExceptionExample {
public static void main(String[] args){
try {
int a1= Integer.parseInt(args[0]);
int a2= Integer.parseInt(args[1]);
int[] array = new int[a1];
array[a2]= a1/ a2;
} catch (ArithmeticException e){
System.out.println("ArithmeticException");
return;
} catch (IllegalArgumentException e){
System.out.println("IllegalArgumentException");
return;
} catch (IndexOutOfBoundsException e){
System.out.println("IndexOutOfBoundsException");
return;
} catch (NegativeArraySizeException e){
System.out.println("NegativeArraySizeException");
return;
}
System.out.println("OK");
return;
}
}
What would be printed to the command line if the program were run as follows?
> java ExceptionExample 100

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