Bird
0
0

What does the virtual method dispatch mechanism in C# primarily allow?

easy🧠 Conceptual Q11 of 15
C Sharp (C#) - Polymorphism and Abstract Classes
What does the virtual method dispatch mechanism in C# primarily allow?
virtual methods let child classes provide their own version of a method. What is the main benefit?
AIt forces the program to call the base class method only.
BIt makes all methods static by default.
CIt disables method overriding in child classes.
DIt allows the program to decide at runtime which method version to call.
Step-by-Step Solution
Solution:
  1. Step 1: Understand virtual method purpose

    Virtual methods allow child classes to override a method and provide their own implementation.
  2. Step 2: Identify when method is chosen

    The actual method called is decided at runtime, based on the object's real type, not the variable's type.
  3. Final Answer:

    It allows the program to decide at runtime which method version to call. -> Option D
  4. Quick Check:

    Virtual method dispatch = runtime method choice [OK]
Quick Trick: Virtual means runtime method choice, not compile-time [OK]
Common Mistakes:
MISTAKES
  • Thinking method is fixed at compile time
  • Confusing virtual with static methods
  • Assuming base method always runs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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