Analyse the following code using The java.lang.Number and its subclasses - Number numberRef = new Integer(0); Double doubleRef = (Double)numberRef;

Analyse the following code using The java.lang.Number and its subclasses -
    Number numberRef = new Integer(0);
    Double doubleRef = (Double)numberRef;


A. There is no such class named Integer. You should use the class Int.
B. The compiler detects that numberRef is not an instance of Double.
C. A runtime class casting exception occurs, since numberRef is not an instance of Double.
D. The program runs fine, since Integer is a subclass of Double.
E. You can convert an int to double, so you can cast an Integer instance to a Double instance.

The correct answer is C


Java

Learn More Multiple Choice Question :