Bird
0
0

Identify the error in this code:

medium📝 Debug Q6 of 15
C Sharp (C#) - Inheritance
Identify the error in this code:
class Base {
  public virtual void Show() {}
}
class Derived : Base {
  public void Show() {}
}
ADerived.Show() must be static
BDerived.Show() must use override keyword
CBase.Show() must be abstract
DNo error, code is correct
Step-by-Step Solution
Solution:
  1. Step 1: Check method overriding rules

    Derived class method intended to override base virtual method must use override keyword.
  2. Step 2: Identify missing override keyword

    Derived.Show() lacks override, so it hides base method instead of overriding.
  3. Final Answer:

    Derived.Show() must use override keyword -> Option B
  4. Quick Check:

    Missing override keyword = error [OK]
Quick Trick: Override keyword required to override virtual methods [OK]
Common Mistakes:
MISTAKES
  • Omitting override keyword causes hiding, not overriding
  • Thinking base method must be abstract
  • Assuming static needed for override

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Sharp (C#) Quizzes