Bird
0
0

Which of the following is the correct syntax to declare an overriding method in C#?

easy📝 Syntax Q3 of 15
C Sharp (C#) - Inheritance
Which of the following is the correct syntax to declare an overriding method in C#?
Apublic abstract void Show()
Bpublic virtual void Show()
Cpublic override void Show()
Dpublic new void Show()
Step-by-Step Solution
Solution:
  1. Step 1: Recall syntax for overriding

    Overriding methods use the override keyword in the derived class method signature.
  2. Step 2: Eliminate other options

    virtual is for base methods, new hides methods, abstract is for abstract methods without body.
  3. Final Answer:

    public override void Show() -> Option C
  4. Quick Check:

    override syntax = public override void Method() [OK]
Quick Trick: Override methods use 'override' keyword in derived class [OK]
Common Mistakes:
MISTAKES
  • Using virtual instead of override in derived class
  • Using new keyword thinking it overrides
  • Missing override keyword causes errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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