Bird
0
0

Which of the following correctly declares an interface named IMovable in C#?

easy📝 Syntax Q3 of 15
C Sharp (C#) - Interfaces
Which of the following correctly declares an interface named IMovable in C#?
Apublic interface IMovable { void Move(); }
Bclass IMovable { void Move(); }
Cinterface IMovable() { void Move(); }
Dpublic class IMovable { void Move(); }
Step-by-Step Solution
Solution:
  1. Step 1: Interface declaration syntax

    In C#, interfaces are declared using the interface keyword optionally preceded by an access modifier.
  2. Step 2: Correct syntax

    public interface IMovable { void Move(); } uses public interface IMovable { void Move(); }, which is correct.
  3. Final Answer:

    public interface IMovable { void Move(); } -> Option A
  4. Quick Check:

    Interfaces use 'interface' keyword, not 'class' [OK]
Quick Trick: Use 'interface' keyword, not 'class' [OK]
Common Mistakes:
MISTAKES
  • Using 'class' instead of 'interface'
  • Adding parentheses after interface name
  • Omitting access modifiers incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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