Bird
0
0

Which of the following is true about default interface methods in C#?

easy🧠 Conceptual Q2 of 15
C Sharp (C#) - Interfaces
Which of the following is true about default interface methods in C#?
AThey allow interfaces to provide method implementations.
BThey require all implementing classes to override the method.
CThey can only be static methods.
DThey cannot access other interface members.
Step-by-Step Solution
Solution:
  1. Step 1: Recall the purpose of default interface methods

    Default interface methods allow interfaces to include method bodies, providing implementations.
  2. Step 2: Evaluate each option

    They allow interfaces to provide method implementations. is correct; options B, C, and D are false because overriding is optional, methods can be instance methods, and default methods can access other members.
  3. Final Answer:

    They allow interfaces to provide method implementations. -> Option A
  4. Quick Check:

    Default interface methods provide implementations = A [OK]
Quick Trick: Default methods add implementation to interfaces [OK]
Common Mistakes:
MISTAKES
  • Believing all default methods must be overridden
  • Thinking default methods are only static
  • Assuming default methods cannot access interface members

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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