Bird
0
0

How do you correctly declare an interface named IPlayable in C#?

easy📝 Syntax Q3 of 15
C Sharp (C#) - Interfaces

How do you correctly declare an interface named IPlayable in C#?

Ainterface IPlayable() { void Play(); }
Bclass IPlayable { void Play(); }
Cinterface IPlayable { void Play(); }
Dinterface IPlayable[] { void Play(); }
Step-by-Step Solution
Solution:
  1. Step 1: Recall interface syntax

    Interfaces use the keyword 'interface' followed by the name and method signatures.
  2. Step 2: Validate options

    interface IPlayable { void Play(); } correctly declares an interface with a method signature.
  3. Final Answer:

    interface IPlayable { void Play(); } -> Option C
  4. Quick Check:

    Interfaces do not use parentheses or brackets in declaration. [OK]
Quick Trick: Use 'interface' keyword without parentheses [OK]
Common Mistakes:
MISTAKES
  • Using class keyword instead of interface
  • Adding parentheses after interface name
  • Using array brackets in interface declaration

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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