Bird
0
0

What is the main purpose of an interface in C#?

easy🧠 Conceptual Q11 of 15
C Sharp (C#) - Interfaces
What is the main purpose of an interface in C#?
ATo define a contract with method and property signatures only
BTo implement all method bodies for a class
CTo store data like variables and constants
DTo create an instance of a class directly
Step-by-Step Solution
Solution:
  1. Step 1: Understand what an interface is

    An interface only declares method and property signatures without implementations.
  2. Step 2: Compare with other options

    Interfaces do not implement methods or store data; they define a contract for classes.
  3. Final Answer:

    To define a contract with method and property signatures only -> Option A
  4. Quick Check:

    Interface purpose = contract definition [OK]
Quick Trick: Interfaces declare methods, they don't implement them [OK]
Common Mistakes:
MISTAKES
  • Thinking interfaces contain method bodies
  • Confusing interfaces with classes
  • Believing interfaces store data

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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