Consider a scenario where you have a base class 'Animal' and derived classes 'Dog' and 'Cat'. If both 'Dog' and 'Cat' classes have a method named 'speak,' but they produce different sounds, this is an example of what OOP concept?

  • Polymorphism
  • Inheritance
  • Encapsulation
  • Abstraction
Polymorphism refers to the ability of objects to take on multiple forms. In this scenario, both 'Dog' and 'Cat' classes exhibit polymorphism by having a 'speak' method with different implementations.
Add your answer
Loading...

Leave a comment

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