What will be the output of the following code? public class ExceptionDemo {…
PYQ DSSSB 2025
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."); } } }
- A.
Exception caught: java.lang.Exception . Execution completed.
- B.
Exception caught: java.lang.ArrayIndexOutOfBoundsException. Execution completed.
- C.
Compilation error
- D.
Exception caught: java.lang.IndexOutOfBoundsException . Execution completed.
Attempted by 209 students.
Sign up free to check your answer
Sign up freeLoading lesson…

