In C#.NET class inheritance, there is no multiple inheritance of classes (a class cannot derive from more than one base class). Assess the statement.

Difficulty: Easy

Correct Answer: Correct — classes can inherit only a single class, though they can implement multiple interfaces.

Explanation:


Introduction / Context:
The question checks C#.NET inheritance capabilities. Unlike C++, C# does not allow multiple inheritance of classes; instead, C# offers multiple interface implementation to achieve polymorphism without the diamond problem complexities found in multiple class inheritance.


Given Data / Assumptions:

  • We are discussing C# classes, not interfaces.
  • Language version differences do not affect this fundamental rule.
  • Interfaces can be implemented in multiples by a single class.


Concept / Approach:
In C#, a class declaration uses a single base class followed by zero or more interfaces, for example: class MyType : BaseType, IFoo, IBar { } Only one class can appear directly after the colon. The language disallows more than one class there, enforcing single inheritance. This model simplifies method resolution and runtime semantics while still allowing broad polymorphism through interfaces.


Step-by-Step Solution:

Declare class: class Derived : Base1, Base2 → invalid (two classes). Declare class: class Derived : Base, IFoo, IBar → valid (one base class, many interfaces). Runtime type checks and interface dispatch handle polymorphic behavior.


Verification / Alternative check:
Attempting to compile a class with two base classes triggers a compiler error. Replacing the second class with an interface resolves the error immediately.


Why Other Options Are Wrong:

  • Full multiple inheritance: not supported in C#.
  • Sealed classes: unrelated; they disallow further derivation but do not enable multiple inheritance.
  • Partial classes: only split a single class across files; not inheritance.
  • .NET variant differences: this rule is universal across C# on .NET Framework and .NET.


Common Pitfalls:
Confusing multiple interface implementation with multiple class inheritance; assuming partial classes or composition are forms of inheritance; or mixing C++ capabilities with C# limitations.


Final Answer:
Correct — classes can inherit only a single class, though they can implement multiple interfaces.

More Questions from Inheritance

Discussion & Comments

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