-
What is the output of this program?
public class exception_Example
{
public static void main(String args[])
{
try
{
int array[] = {11, 21,31 , 41, 51};
for (int k = 0; k < 5; ++k)
System.out.print(array[k]);
int p = 1/0;
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.print("I");
}
catch(ArithmeticException e)
{
System.out.print("L");
}
}
}
-
- 1121314151L
- 112131
- 1121314151U
- 112131451
- L1121314151
Correct Option: A
There can be more than one catch of a single try block. Here Arithmetic exception occurs instead of Array index out of bound exception hence L is printed after 1121314151.