Virtual method behavior when not overridden in a derived class — choose the correct statement.
C# Programming
Polymorphism
Difficulty: Easy
Choose an option
Answer
Correct Answer: If a derived class does not override a virtual method, the base class implementation is used.
Explanation
Introduction / Context:Understanding default virtual method behavior is key to predicting runtime dispatch in C#.
Given Data / Assumptions:
- We have a base class with a virtual member.
- The derived class may or may not override it.
Concept / Approach:If the derived class does not provide an override, the base virtual implementation is used for calls, including those made through base references.
Why Other Options Are Wrong:
- A: Abstract classes cannot be instantiated at all.
- B: Methods are non-virtual by default unless marked virtual/abstract/override.
- D: Omitting override does not auto-override; it either hides (with new) or just defines a separate member.
- E: Derived classes can provide their own overrides.
Final Answer:If a derived class does not override a virtual method, the base class implementation is used.