Multiple choice

What is the output of the given program code?

public class ScopeTest
{
public static void main(String[] args)
{
int [] xx = null;
for(int i=0;i

  1. Null

  2. Java.lang.NullPointerException

  3. 0

  4. Compilation fails

  5. None of these

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

This is the correct choice. Java.lang.NullPointerException will be thrown as we are trying to access the array that has been assigned a null value. So, exception will be thrown at run time. So, this is the correct choice.