111k views
1 vote
The mechanism of selecting the appropriate method for a particular object in a class hierarchy:

a) Inheritance
b) Encapsulation
c) Polymorphism
d) Abstraction

1 Answer

0 votes

Final answer:

Polymorphism is the mechanism for selecting the appropriate method for an object in a class hierarchy, allowing different classes to respond uniquely to the same call.

Step-by-step explanation:

The mechanism of selecting the appropriate method for a particular object in a class hierarchy is known as polymorphism. Polymorphism allows objects of different classes within the same hierarchy to respond differently to the same method call. For example, suppose you have a base class called Animal with a method called speak. If Dog and Cat are subclasses of Animal, polymorphism allows both to have their own implementation of the speak method. When you call speak on an Animal object that is actually a Dog, it will execute the Dog's version of the method.

User Abhishek Ringsia
by
8.6k points