Bird
Raised Fist0

Identify the error in the following interface declaration:

medium📝 Debug Q14 of Q15
C Sharp (C#) - Interfaces
Identify the error in the following interface declaration:
interface ITest {
  void Run() {}
}
AMissing semicolon after method declaration
BMethod name must be lowercase
CInterface name must start with lowercase 'i'
DInterfaces cannot have method bodies
Step-by-Step Solution
Solution:
  1. Step 1: Check method declaration in interface

    Interfaces only declare method signatures without bodies (no curly braces).
  2. Step 2: Validate other syntax rules

    Method names can be any case; interface names usually start with uppercase 'I'. Semicolon is required after signature.
  3. Final Answer:

    Interfaces cannot have method bodies -> Option D
  4. Quick Check:

    Interface methods = signatures only [OK]
Quick Trick: No method bodies allowed inside interfaces [OK]
Common Mistakes:
MISTAKES
  • Adding method bodies inside interfaces
  • Confusing naming conventions with syntax errors
  • Omitting semicolon after method signature

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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