Difficulty: Easy
Correct Answer: Correct — C# has only one inheritance form; you cannot declare private/protected inheritance.
Explanation:
Introduction / Context:
The question contrasts C++ and C#. In C++, you can write class D : private B
or class D : protected B
to adjust base-member accessibility in the derived type. In C#, inheritance syntax does not support such specifiers for classes, so there is no notion of “private” or “protected” inheritance for classes.
Given Data / Assumptions:
Concept / Approach:
The C# class declaration syntax uses a colon followed by the base class name (if any) and implemented interfaces. There is no grammar to place private
or protected
before the base class name to alter how members are exposed. Public, protected, internal, and private modifiers control member accessibility in the declaring class, and derived classes observe those rules; inheritance itself has no “mode” to tighten them for the derived public surface.
Step-by-Step Solution:
Verification / Alternative check:
Compiling a “private inheritance” attempt in C# yields syntax errors. Interfaces can be listed freely, but again, no inheritance-mode keywords exist for classes.
Why Other Options Are Wrong:
Common Pitfalls:
Projecting C++ features onto C#, or confusing member access modifiers with inheritance-mode specifiers.
Final Answer:
Correct — C# has only one inheritance form; you cannot declare private/protected inheritance.
Discussion & Comments