Bird
Raised Fist0

Why might default interface methods cause ambiguity in multiple interface inheritance?

hard🧠 Conceptual Q10 of Q15
C Sharp (C#) - Interfaces
Why might default interface methods cause ambiguity in multiple interface inheritance?
ABecause default methods must be static.
BBecause default methods cannot be overridden by classes.
CBecause interfaces cannot inherit from other interfaces.
DBecause multiple interfaces can provide different default implementations for the same method.
Step-by-Step Solution
Solution:
  1. Step 1: Understand multiple interface inheritance

    A class can implement multiple interfaces that may have default methods with the same signature.
  2. Step 2: Identify ambiguity cause

    If interfaces provide different default implementations for the same method, the compiler cannot decide which to use, causing ambiguity.
  3. Final Answer:

    Because multiple interfaces can provide different default implementations for the same method. -> Option D
  4. Quick Check:

    Multiple defaults cause ambiguity = A [OK]
Quick Trick: Multiple default methods with same signature cause ambiguity [OK]
Common Mistakes:
MISTAKES
  • Thinking default methods cannot be overridden
  • Believing interfaces cannot inherit
  • Assuming default methods must be static

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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