Bird
Raised Fist0

What is the main purpose of default interface methods in C#?

easy🧠 Conceptual Q11 of Q15
C Sharp (C#) - Interfaces
What is the main purpose of default interface methods in C#?
AAllow interfaces to have method bodies with default behavior
BForce all implementing classes to override every method
CPrevent interfaces from having any methods
DMake interfaces behave like abstract classes
Step-by-Step Solution
Solution:
  1. Step 1: Understand interface limitations before default methods

    Interfaces could only declare methods without bodies, forcing all implementations to define them.
  2. Step 2: Recognize the role of default interface methods

    Default interface methods allow interfaces to provide a method body, so implementing classes can use or override it.
  3. Final Answer:

    Allow interfaces to have method bodies with default behavior -> Option A
  4. Quick Check:

    Default interface methods = method bodies in interfaces [OK]
Quick Trick: Default interface methods add bodies to interfaces [OK]
Common Mistakes:
MISTAKES
  • Thinking interfaces cannot have any method bodies
  • Confusing default methods with abstract methods
  • Believing all methods must be overridden

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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