Bird
0
0

What will happen if a class implements two interfaces with the same method signature but different return types?

medium📝 Predict Output Q5 of 15
C Sharp (C#) - Interfaces
What will happen if a class implements two interfaces with the same method signature but different return types?
ACompile-time error due to ambiguity
BClass must implement both methods separately
CRuntime error when calling the method
DThe method from the first interface is used
Step-by-Step Solution
Solution:
  1. Step 1: Understand method signature conflict

    Two interfaces with same method name but different return types cause ambiguity.
  2. Step 2: Check C# rules for interface implementation

    C# compiler cannot resolve which method to implement, causing compile-time error.
  3. Final Answer:

    Compile-time error due to ambiguity -> Option A
  4. Quick Check:

    Conflicting interface methods cause compile error [OK]
Quick Trick: Conflicting method signatures in interfaces cause compile errors [OK]
Common Mistakes:
MISTAKES
  • Assuming runtime error instead of compile error
  • Thinking class can implement both methods without conflict
  • Believing one interface method overrides the other silently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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