Which of the following Object Oriented Programming concept provides usability ?
APolymorphism
BDynamic binding
CInheritance
DMessage Passing
Answer:
C. Inheritance
Read Explanation:
- Inheritance is the fundamental Object-Oriented Programming (OOP) concept that enables reusability.
- It allows a new class (derived class or subclass) to acquire the properties and behaviors (methods and fields) of an existing class (base class or superclass).
- By utilizing inheritance, developers avoid writing redundant code, as common functionalities can be defined once in a parent class and extended by multiple child classes.
- Key benefits of inheritance include:
- Code Efficiency: Reduces the amount of duplicate code across a software project.
- Maintainability: Changes made to a base class automatically propagate to its subclasses, simplifying updates.
- Hierarchy Creation: Establishes a natural relationship between objects, such as 'is-a' relationships (e.g., a 'Car' is a 'Vehicle').
- In contrast to other OOP pillars:
- Encapsulation focuses on data hiding and bundling data with methods.
- Polymorphism allows entities to take multiple forms, primarily through method overloading and overriding.
- Abstraction focuses on hiding complex implementation details and showing only the essential features of an object.
