QHow does inheritance in OOP promote code reusability?
Question Info
Choose the Best Option
Click any option to instantly check if you're correct.
Explanation
Inheritance is a key feature of object-oriented programming that enables a new class to inherit the properties and methods of an existing class. This mechanism promotes code reusability by allowing developers to create new classes that build upon existing ones without rewriting code. When a class inherits from another class, it automatically gains all the features of the parent class, and it can add new features or modify existing ones. This hierarchical relationship reduces redundancy and makes the codebase more manageable and scalable. It also simplifies maintenance and updates, as changes in the parent class can propagate to all derived classes, ensuring consistency across the application.
Share This Question
Challenge a friend or share with your study group.