Bird
0
0

Which of the following is the correct way to declare a method that demonstrates polymorphism in C#?

easy📝 Syntax Q12 of 15
C Sharp (C#) - Polymorphism and Abstract Classes
Which of the following is the correct way to declare a method that demonstrates polymorphism in C#?
Apublic void Draw() { }
Bpublic void Draw(int x) { }
Cpublic virtual void Draw() { }
Dpublic static void Draw() { }
Step-by-Step Solution
Solution:
  1. Step 1: Identify polymorphic method declaration

    In C#, polymorphism is often shown using virtual methods that can be overridden.
  2. Step 2: Check method options

    Only 'public virtual void Draw()' allows derived classes to override and show polymorphism.
  3. Final Answer:

    public virtual void Draw() { } -> Option C
  4. Quick Check:

    Virtual method enables polymorphism [OK]
Quick Trick: Use 'virtual' keyword to enable polymorphism [OK]
Common Mistakes:
MISTAKES
  • Choosing static methods which cannot be overridden
  • Ignoring the virtual keyword for polymorphism
  • Confusing method overloading with polymorphism

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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