Difficulty: Easy
Correct Answer: Use base functionality; override base functionality; implement new functionality; implement polymorphic behavior
Explanation:
Introduction / Context:
Inheritance is a core pillar of OOP in C#. It enables code reuse, extension, and polymorphism. This question asks you to identify the full capabilities that inheritance can provide (and to avoid mixing in composition/containership).
Given Data / Assumptions:
Concept / Approach:
With inheritance you can reuse base implementations as-is, override virtual members to alter behavior, add new members to extend functionality, and leverage polymorphism so that base references can target derived instances with behavior determined at runtime.
Step-by-Step Solution:
virtual
/override
or new
to change behavior.Implement new functionality → add new methods/properties/fields in the derived class.Implement polymorphic behavior → override virtual members so calls dispatched via a base reference use the derived implementation.Containership → not part of inheritance; it is composition/aggregation.
Verification / Alternative check:
Create a base with a virtual method and a derived override; call through a base reference to observe polymorphism. Add a new member in the derived class to confirm extension capability.
Why Other Options Are Wrong:
Any set including containership is mixing a different relationship. Sets omitting polymorphism are incomplete regarding inheritance power.
Common Pitfalls:
Assuming “inheritance = code reuse only.” It also enables runtime substitution and behavior variation.
Final Answer:
Use the base functionality; override base functionality; implement new functionality; implement polymorphic behavior
Discussion & Comments