How does the concept of polymorphism in Object-Oriented Programming enhance code reusability?

  • It allows objects of different classes to be treated as objects of a common base class.
  • It eliminates the need for inheritance.
  • It promotes static binding of methods.
  • It restricts the ability to extend and modify classes.
Polymorphism in OOP enhances code reusability by allowing objects of different classes to be treated as objects of a common base class. This enables more flexible and extensible code as you can work with various objects without knowing their specific types, which encourages reuse and simplifies code maintenance.
Add your answer
Loading...

Leave a comment

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