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."); } } }

  1. A.

    Exception caught: java.lang.Exception . Execution completed.

  2. B.

    Exception caught: java.lang.ArrayIndexOutOfBoundsException. Execution completed.

  3. C.

    Compilation error

  4. D.

    Exception caught: java.lang.IndexOutOfBoundsException . Execution completed.

Attempted by 209 students.

Sign up free to check your answer

Sign up free

Explore the full course: Dsssb Tgt Computer Science Paper 2

Loading lesson…