C#.NET inheritance facts — select the correct statements. A derived class object contains all the base-class data. Inheritance cannot suppress base-class functionality. A derived class may not be able to access all the base-class data. Inheritance cannot extend base-class functionality. During object construction in an inheritance chain, construction happens from base towards derived.
-
A1, 2, 4
-
B2, 4, 5
-
C1, 3, 5
-
D2, 4
-
ENone of these
Answer
Correct Answer: 1, 3, 5
Explanation
Introduction / Context:This question surveys several foundational truths about inheritance in C#. Understanding what is included in a derived object, accessibility of base data, and construction order is essential.
Given Data / Assumptions:
- We are dealing with standard single inheritance as in C# classes.
- “Suppress/extend” refers to behavior changes via
override/newand adding members.
Concept / Approach:A derived object physically contains base-class instance fields. It may not be able to access some of them (like private) even though they exist. Construction runs base → derived. Derived classes can both extend and override base functionality.
Step-by-Step Solution:
(1) True — base fields are part of the derived instance layout.(2) False — overriding or hiding can change/suppress observed behavior.(3) True —private base members are not accessible in the derived type.(4) False — derived types can add new members (extend functionality).(5) True — base constructor executes before derived constructor.Verification / Alternative check:Reflect a derived instance; you will see fields from the base. Attempt to access a private base field from the derived → compile error.
Why Other Options Are Wrong:They include (2) or (4), both of which misstate how overriding and class extension work.
Common Pitfalls:Equating “not accessible” with “does not exist.” The data exists in the object even if not accessible by name in code.
Final Answer:1, 3, 5