The Dog class and the Cat class inherit from the Animal class. The Animal class includes a
breathe() method and a speak() method. If the speak() method is called from an object of
type Dog, the result is a bark. If the speak() method is called from an object of type Cat, the
result is a meow.
Which term is used to describe this object-oriented concept?
A.
multiple inheritance
B.
polymorphism
C.
data hiding
D.
encapsulation
Should be B (polymorphism).
It’s B because we’re overriding the speak method in each derived class of the animal class which is the base class.
B
B: Polymorphism
Encapsulation is the hidden or black box aspect of a class. The methods described above are clearly exposed, thus are not encapsulated.
i wonder who is giving that answer…? does he have enough learning process…?