Which term is used to describe this object-oriented concept?

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?

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



Leave a Reply 5

Your email address will not be published. Required fields are marked *


Christian Zalto

Christian Zalto

Should be B (polymorphism).

rachid belouche

rachid belouche

It’s B because we’re overriding the speak method in each derived class of the animal class which is the base class.

DB7

DB7

B: Polymorphism

Encapsulation is the hidden or black box aspect of a class. The methods described above are clearly exposed, thus are not encapsulated.

reallydontknow

reallydontknow

i wonder who is giving that answer…? does he have enough learning process…?