C#.NET — What can inheritance facilitate? Choose the best set.

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:

  • Containership (composition/aggregation) is a separate design mechanism from inheritance.
  • Polymorphism in C# typically involves virtual methods and overrides.


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:

Use base functionality → the derived class inherits accessible members and can call them.Override base functionality → using 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

More Questions from Inheritance

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion