Solved

Let Dog Be a Subclass of Animal, and Suppose Animal

Question 11

Multiple Choice

Let Dog be a subclass of Animal, and suppose Animal has a method called speak() that is overridden in the Dog class. Consider the following code. Animal spot = new Dog() ;
Spot.speak() ;

Which of the following is true?


A) This code will result in a compile-time error.
B) This code will result in a run-time error.
C) The speak method defined in the Animal class will be called.
D) The speak method defined in the Dog class will be called.
E) The speak method will not be called at all.

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents