Which term is used to describe the ability of different classes to be treated…
2025
Which term is used to describe the ability of different classes to be treated as objects of the same parent class?
- A.
Overloading
- B.
Polymorphism
- C.
Abstraction
- D.
Encapsulation
Attempted by 121 students.
Show answer & explanation
Correct answer: B
Correct Answer:
B) Polymorphism
English Explanation:
Polymorphism is an Object-Oriented Programming (OOP) feature that allows objects of different classes to be treated as objects of the same parent class.
It enables one interface to be used for different types of objects. Through inheritance and method overriding, different classes can provide different implementations of the same method.
Example:
class Animal
{
public:
virtual void sound() {}
};
class Dog : public Animal
{
};
class Cat : public Animal
{
};Here, Dog and Cat objects can both be treated as Animal objects. This is called polymorphism.