Multiple choice technology programming languages

Given: 1. class Zippy { 2. String[] x; 3. int[] a [] = {{1,2}, {l}}; 4. Object c = new long [4] ; 5. Object[] d = x; 6. } What is the result?

  1. Compilation succeeds.

  2. Compilation fails due only to an error on line 3.

  3. Compilation fails due only to an error on line 4.

  4. Compilation fails due only to an error on line 5.

  5. Compilation fails due only to an error on line 3 and 5.

  6. Compilation fails due only to an error on line 3,4 and 5.

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

All lines compile correctly. Line 3's array syntax 'int[] a []' is valid (array of arrays). Line 4 can assign a long array to an Object reference (upcasting). Line 5 assigns a String array to an Object array reference (covariant arrays are allowed in Java).