What is inheritance in OOP and how does it facilitate code reuse?

  • It is a mechanism to create a new class using the properties and behaviors of an existing class
  • It is a method for defining variables in OOP
  • It is a way to create instances of classes
  • It is used for code duplication in OOP
Inheritance in OOP allows a new class (derived or child class) to inherit properties and behaviors from an existing class (base or parent class). It facilitates code reuse by promoting a hierarchical structure, reducing redundancy, and promoting modular design. The child class can reuse the methods and attributes of the parent class, promoting efficiency and maintainability.
Add your answer
Loading...

Leave a comment

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