Multiple choice

What is the output of the given program?

public class ScopeTest
{
public static void main (String [] args)
{
int[][] xx[][][] = null;
System.out.println(xx);
}
}

  1. Compilation Fails

  2. Null

  3. 0

  4. Java.lang.ArrayIndexOutOfBoundException

  5. Java.lang.NullPointerException

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

This is the correct choice because an array variable (here xx) can very well have the null value. Null is the reserved constant used in Java to represent a void reference, i.e. a pointer to nothing. Internally, it is just a binary 0, but in the high level Java language, it is a magic constant, quite distinct from zero, that internally could have any representation. So, this answer is correct.