Card 19 / 76: What Java code is used for declaring and initializing a null object?
A)
Object object = new Object();
B)
Object object = new Object(null);
C)
Object object = null;
D)
Object object = null();
Answer:
C) Object object = null;
Previous Card | ← Previous Card Button |
Next Card | → Next Card Button |
Flip Card | Space-Bar |
A, B, and D are incorrect.
A is incorrect because when the new keyword is used, it initializes the object to a new non-null object.
B is incorrect for the same reason as A, plus the Object constructor does not accept any arguments.
D is incorrect because null() is a made up method and is invalid in Java.
|