Bird
0
0

Identify the error in this code snippet:

medium📝 Debug Q14 of 15
C Sharp (C#) - Polymorphism and Abstract Classes
Identify the error in this code snippet:
abstract class Shape {
    public abstract double Area();
}

class Circle : Shape {
    public double Area() {
        return 3.14 * 5 * 5;
    }
}
ACircle must declare Area() as override
BShape cannot have abstract methods
CCircle cannot inherit from Shape
DArea method should return int, not double
Step-by-Step Solution
Solution:
  1. Step 1: Check abstract method override rules

    When a class inherits an abstract method, it must override it using the override keyword.
  2. Step 2: Identify missing override keyword

    The Circle class defines Area() but misses override, causing a compile error.
  3. Final Answer:

    Circle must declare Area() as override -> Option A
  4. Quick Check:

    Override keyword required for abstract methods [OK]
Quick Trick: Override abstract methods with 'override' keyword [OK]
Common Mistakes:
MISTAKES
  • Omitting override keyword
  • Thinking abstract methods can be ignored
  • Confusing return types

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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