Bird
0
0

Which of the following is the correct syntax to declare an interface named IMyInterface in C#?

easy📝 Syntax Q12 of 15
C Sharp (C#) - Interfaces
Which of the following is the correct syntax to declare an interface named IMyInterface in C#?
Ainterface IMyInterface { void MyMethod(); }
Bclass IMyInterface { void MyMethod(); }
Cinterface IMyInterface() { void MyMethod(); }
Dinterface IMyInterface[] { void MyMethod(); }
Step-by-Step Solution
Solution:
  1. Step 1: Check the keyword and name format

    Interfaces use the keyword interface followed by the name without parentheses or brackets.
  2. Step 2: Validate method declaration inside interface

    Methods inside interfaces have only signatures ending with semicolons, no bodies.
  3. Final Answer:

    interface IMyInterface { void MyMethod(); } -> Option A
  4. Quick Check:

    Correct interface syntax = interface IMyInterface { void MyMethod(); } [OK]
Quick Trick: Use 'interface Name { }' without parentheses or brackets [OK]
Common Mistakes:
MISTAKES
  • Using class keyword instead of interface
  • Adding parentheses after interface name
  • Using brackets [] after interface name

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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