Question discussion

What is the output of the following Java code? public class Test { public static void main(String[] args) { try { int[] arr = new int[5]; a…

557Medium DSSSB TGT Computer Science 0 replies 1 views
0
What is the output of the following Java code? public class Test { public static void main(String[] args) { try { int[] arr = new int[5]; arr[10] = 50; } catch (ArithmeticException e) { System.out.println("Arithmetic"); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("ArrayIndex"); } finally { System.out.println("Finally"); } } }
  • AArithmetic Finally
  • BArrayIndex Finally
  • CFinally only
  • DCompilation error, unreachable catch block
Correct answer: B

Discussion 0

Nobody has replied yet. Start the discussion!