Bird
0
0

What does the virtual keyword do in a C# base class method?

easy🧠 Conceptual Q1 of 15
C Sharp (C#) - Inheritance
What does the virtual keyword do in a C# base class method?
APrevents the method from being overridden
BMakes the method static
CAllows the method to be overridden in derived classes
DMarks the method as private
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of virtual in base class

    The virtual keyword marks a method so derived classes can provide their own implementation.
  2. Step 2: Compare with other keywords

    Without virtual, methods cannot be overridden. It does not make methods static or private.
  3. Final Answer:

    Allows the method to be overridden in derived classes -> Option C
  4. Quick Check:

    virtual keyword = Allows overriding [OK]
Quick Trick: Virtual means method can be changed in child classes [OK]
Common Mistakes:
MISTAKES
  • Thinking virtual makes method static
  • Confusing virtual with override
  • Assuming virtual restricts access

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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