Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

d. Who are important leaders and heroes of the group?

Answered: 1 week ago