-
What is the output of this program?
public class ExceptionHandling_Example
{
public static void main(String args[])
{
try
{
int array[] = {10, 20,30 , 40, 50};
for (int K = 0; K < 5; ++K)
System.out.print(array[K]);
int p = 1/0;
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.print("L");
}
catch(ArithmeticException e)
{
System.out.print("U");
}
}
}
-
- 1020304050
- 10203050
- 1020304050U
- 20304050U
- 304050U
Correct Option: C
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 U is printed after 1020304050