Question:

What is inheritance?

Show Hint

Inheritance is a powerful feature in OOP that promotes the reuse of code and simplifies software maintenance.
Updated On: Oct 8, 2025
Hide Solution
collegedunia
Verified By Collegedunia

Solution and Explanation

Inheritance is a fundamental concept in object-oriented programming (OOP) that allows one class (called a subclass or child class) to inherit properties and methods from another class (called a superclass or parent class). This promotes code reuse and allows the subclass to extend or modify the functionality of the superclass.

Single Inheritance: A subclass inherits from only one superclass.
Multiple Inheritance: A subclass inherits from more than one superclass, which is supported in some OOP languages like Python but not in others like Java.
Method Overriding: A subclass can override a method of the superclass to provide a more specific implementation.
Code Reusability: Inheritance helps reduce code duplication by allowing common functionality to be written once in the parent class and reused in child classes.
Conclusion:
Inheritance allows for creating hierarchical class structures, enabling code reuse and extension of existing functionality.
Was this answer helpful?
0
0