Bird
0
0

Which of the following correctly implements the Display() method explicitly from interface IShow in class Example?

easy📝 Syntax Q3 of 15
C Sharp (C#) - Interfaces
Which of the following correctly implements the Display() method explicitly from interface IShow in class Example?
Avoid Display() { Console.WriteLine("Display called"); }
Bpublic void Display() { Console.WriteLine("Display called"); }
Cvoid IShow.Display() { Console.WriteLine("Display called"); }
Dpublic void IShow.Display() { Console.WriteLine("Display called"); }
Step-by-Step Solution
Solution:
  1. Step 1: Understand explicit implementation syntax

    Explicit interface methods must be implemented with the interface name prefix and without an access modifier.
  2. Step 2: Analyze options

    void IShow.Display() { Console.WriteLine("Display called"); } correctly uses void IShow.Display() without public. public void Display() { Console.WriteLine("Display called"); } and C are implicit implementations. public void IShow.Display() { Console.WriteLine("Display called"); } incorrectly uses public with explicit implementation.
  3. Final Answer:

    void IShow.Display() { Console.WriteLine("Display called"); } -> Option C
  4. Quick Check:

    Explicit methods omit access modifiers and use interface prefix [OK]
Quick Trick: Explicit methods use interface prefix without access modifier [OK]
Common Mistakes:
MISTAKES
  • Adding public modifier to explicit interface methods
  • Omitting interface name in method signature
  • Confusing implicit and explicit implementation syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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