Multiple choice technology programming languages

public class Play { public static void main(String[] args) { int[][] a = {{5,2,4,7}, {9,2}, {3,4}}; int[] b = a[1]; int[][] b1= new int[3][]; int a2 = b[2]; System.out.println(a2); } }

  1. 2

  2. 4

  3. Exception

  4. Compilation error

  5. 9

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The array a has a[1] = {9,2} which is an int array of length 2 (indices 0 and 1). When we try to access b[2] where b = a[1], we're accessing index 2 in an array that only has indices 0 and 1. This causes an ArrayIndexOutOfBoundsException at runtime, not a compilation error (the array sizes are determined at runtime for jagged arrays).