Creating Superclasses and Subclasses

AP Computer Science A· difficulty 3/5

public abstract class Shape {
    public abstract double area();
}
public abstract class Polygon extends Shape {
    public int sides() { return 0; }
}

What is true?

  • A

    Polygon must implement area()

  • B

    Polygon compiles; it remains abstract because area() is unimplemented

    check_circle
  • C

    Polygon cannot be abstract

  • D

    Compile-time error: Polygon cannot extend Shape

Explanation

An abstract subclass need not implement abstract methods; concrete descendants will.

Want 10 more like this — adaptive to your weak spots?

Related questions