Card 32 / 76: What is the correct way to initialize a variable declared as a Penguin as a new Penguin object?
A)
Penguin p;
B)
Penguin p = new Penguin();
C)
Penguin p = new Penguin[];
D)
Penguin p = Penguin();
Answer:
B) Penguin p = new Penguin();
Previous Card | ← Previous Card Button |
Next Card | → Next Card Button |
Flip Card | Space-Bar |
A, C, and D are incorrect.
A is incorrect because it declares a Penguin object but does not initialize it.
C is incorrect because [] is used when it should be ().
D is incorrect because it omits the new keyword.
|