What is the output of the Java code int m = new int; System.out.println(m == null);?
Correct answer C. true
Explanation
Java builds two-dimensional arrays as arrays of arrays. The expression new int[2][] creates only the outer array, whose elements are references of type int[] with the default value null, so the comparison is true. Comparing null is safe, whereas reading m[0][0] before assigning an inner array would throw a NullPointerException.
Answer checked How we write and check questions
Discussion