Bird
Raised Fist0

Why do we use interfaces in C# programming?

easy🧠 Conceptual Q11 of Q15
C Sharp (C#) - Interfaces
Why do we use interfaces in C# programming?
ATo define a contract that classes must follow
BTo store data like variables
CTo create graphical user interfaces
DTo write comments in code
Step-by-Step Solution
Solution:
  1. Step 1: Understand the purpose of interfaces

    Interfaces specify methods that a class must implement, acting like a contract.
  2. Step 2: Compare other options

    Options B, C, and D describe unrelated concepts: data storage, UI design, and comments.
  3. Final Answer:

    To define a contract that classes must follow -> Option A
  4. Quick Check:

    Interface purpose = contract [OK]
Quick Trick: Interfaces define required methods, not data or UI [OK]
Common Mistakes:
MISTAKES
  • Confusing interfaces with classes
  • Thinking interfaces store data
  • Mixing interfaces with UI design

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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