Multiple Choice Question

Quiz Guidelines

 

QID: 
21
Question: 

What will happen when the following code is compiled and run?

class AX{

static int[] x = new int[0];

static{

x[0] = 10;

}

public static void main(String[] args){

AX ax = new AX();

}

}

Select 1 option

A. It will throw NullPointerException at runtime.

B. It will throw ArrayIndexOutOfBoundsException at runtime.

C. It will throw ExceptionInInitializerError at runtime.

D. It will not compile.

Q&A Set: