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.
Loading...
Related Quiz
- What are some common strategies for resolving merge conflicts in Git?
- How does containerization help in the deployment process?
- What are the differences between the Observer and Publisher-Subscriber design patterns?
- Which of the following is NOT a common level of severity used in logging systems?
- Using strong _______ is important for securing user passwords.