Bird
Raised Fist0

How should you implement this in C#?

hard🚀 Application Q9 of Q15
C Sharp (C#) - Polymorphism and Abstract Classes
You have an abstract class with an abstract method and a concrete method. You want to extend it with a subclass that overrides the abstract method and also calls the base concrete method. How should you implement this in C#?
AOverride the abstract method and inside it call base.ConcreteMethod()
BOverride the concrete method and call base.AbstractMethod()
CCannot call base methods from subclass
DMake all methods abstract to avoid calling base
Step-by-Step Solution
Solution:
  1. Step 1: Understand abstract and concrete methods in base class

    Abstract methods must be overridden. Concrete methods can be called from subclass using base keyword.
  2. Step 2: Implement subclass method

    Override abstract method and inside it call base.ConcreteMethod() to reuse base functionality.
  3. Final Answer:

    Override the abstract method and inside it call base.ConcreteMethod() -> Option A
  4. Quick Check:

    Use base keyword to call concrete base methods [OK]
Quick Trick: Use base.Method() to call concrete base methods in override [OK]
Common Mistakes:
MISTAKES
  • Trying to call abstract methods with base
  • Overriding concrete methods unnecessarily
  • Making all methods abstract to avoid base calls

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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