0
What will be the output of the following code?
public class ExceptionDemo {
public static void main(String[] args) {
try {
int[] numbers = {1, 2, 3};
System.out.println(numbers[5]);
} catch (Exception e) {
System.out.println("Exception caught: " + e.getClass().getName());
} finally {
System.out.println("Execution completed.");
}
}
}- AException caught: java.lang.Exception . Execution completed.
- BException caught: java.lang.ArrayIndexOutOfBoundsException. Execution completed.
- CCompilation error
- DException caught: java.lang.IndexOutOfBoundsException . Execution completed.
Correct answer: B