Bird
0
0

Identify the error in this code:

medium📝 Debug Q6 of 15
C Sharp (C#) - Interfaces
Identify the error in this code:
interface IShape { double Area(); }
class Circle : IShape { public double Area { return 3.14 * radius * radius; } private double radius; }
Aradius must be public
BCircle must not implement IShape
CInterface methods cannot return double
DArea should be a method, not a property
Step-by-Step Solution
Solution:
  1. Step 1: Compare interface and class member signatures

    IShape declares Area as a method, but Circle defines Area as a property.
  2. Step 2: Understand implementation requirements

    Class must implement interface methods exactly as declared, so Area must be a method.
  3. Final Answer:

    Area should be a method, not a property -> Option D
  4. Quick Check:

    Interface method must be implemented as method [OK]
Quick Trick: Match method signatures exactly when implementing interfaces [OK]
Common Mistakes:
MISTAKES
  • Implementing method as property
  • Changing return type
  • Ignoring interface method signature

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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