Analyze the following code. Number[] numberArray = new Integer[2]; numberArray[0] = new Double(1.5);

Analyze the following code.
    Number[] numberArray = new Integer[2];
    numberArray[0] = new Double(1.5);


A. You cannot use Number as a data type since it is an abstract class.
B. Since each element of numberArray is of the Number type, you cannot assign an Integer object to it.
C. Since each element of numberArray is of the Number type, you cannot assign a Double object to it.
D. At runtime, new Integer[2] is assigned to numberArray. This makes each element of numberArray an Integer object. So you cannot assign a Double object to it.

The correct answer is D


Java

Learn More Multiple Choice Question :