Multiple choice technology programming languages

Class C { public static void main(String[] args) { int[]a1[]=new int[3][3]; //3 int a2[4]={3,4,5,6}; //4 int a2[5]; //5 }} What is the result of attempting to compile and run the program ?.

  1. compiletime error at lines

  2. compiltime error at line 4,5

  3. compiletime error at line 3

  4. Runtime Exception

  5. None of the above

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

In Java, arrays must be declared with brackets after the type or variable name, not C-style syntax. Line 3 uses correct syntax int[][] a1 = new int[3][3]. Line 4 attempts C-style declaration int a2[4] which is invalid. Line 5 declares int a2[5] without initialization using C-style which is also invalid.