Card 67 / 76: Given that the FoodStore class extends the Store class, which of the following statements is/are valid? (Choose all that apply.)
A)
Store store = new FoodStore();
B)
FoodStore foodStore = new Store();
C)
Object obj = new FoodStore();
D)
Object obj = new Store();
Answer:
A) Store store = new FoodStore();
C) Object obj = new FoodStore();
D) Object obj = new Store();
Previous Card | ← Previous Card Button |
Next Card | → Next Card Button |
Flip Card | Space-Bar |
A is correct because Store is a base class for FoodStore.
C is correct because Object is a base class for FoodStore. The Object class is always the base class for every object. Store implicitly extends Object, Store is extended by FoodStore, and so
FoodStore extends Object.
D is correct because Store implicitly extends Object.
B is incorrect because a FoodStore object cannot be initialized with a more general class.
|