Correct option is C
Inheritance is a key feature of
object-oriented programming (OOP) that allows a class (child or derived class) to
inherit properties and methods from another class (parent or base class). This promotes
code reusability, as common functionality can be written once in the base class and reused across multiple derived classes without duplicating code. This reduces redundancy and simplifies the codebase.
Important Key Points:
1.
Code Reusability: Inheritance eliminates the need to rewrite code for similar functionalities, making the code more modular and maintainable.
2.
Hierarchy Creation: It enables the creation of a class hierarchy, which simplifies the management of related classes.
3.
Extensibility: Developers can extend existing functionality in derived classes by adding new properties or overriding inherited methods.
Knowledge Booster:
·
Faster Execution: Inheritance does not necessarily improve execution speed; it focuses on structuring code efficiently.
·
Enhanced Readability: While inheritance promotes better structure, readability depends on how well the code is written.
·
Simplified Debugging: Debugging might become complex in deep inheritance hierarchies due to multiple levels of method calls.
·
Memory Management: Inheritance does not directly impact memory management; it focuses on organizing and reusing code.