Course contentsShow
← Java
Lesson 483 of 2,87012. Abstract Classes and InterfacesFree lesson

Abstract Subclasses: Deferring Implementation

Creating abstract subclasses that can inherit abstract methods without implementing them, passing responsibility down the hierarchy.

Abstract Subclasses: Deferring Implementation

What you'll learn: How an abstract subclass can inherit abstract methods without implementing them, pushing the responsibility further down the inheritance hierarchy.

The Core Idea

When you extend an abstract class, you don't have to implement all its abstract methods immediately. You can create another abstract class that defers some or all of those implementations to its own subclasses. This is perfectly legal—Java lets you pass the implementation responsibility down the chain until a concrete (non-abstract) class finally provides the actual method bodies.

Why Would You Do This?

Think of it like a chain of command in a company. The CEO (top abstract class) defines broad responsibilities. The department heads (abstract subclasses) might add more specific tasks but still leave some details to team leads. Only the individual employees (concrete classes) actually perform all the work.

This approach is useful when your inheritance hierarchy has multiple layers of abstraction, with each layer adding its own abstract requirements while deferring others.

The Rules

  • An abstract subclass can implement some, none, or even add new abstract methods
  • It remains abstract if any abstract methods go unimplemented
  • Only a concrete subclass must implement all inherited abstract methods
  • Each abstract layer can progressively refine the contract

Simple Example Structure

abstract class Shape {
    abstract double area();
    abstract double perimeter();
}

abstract class Polygon extends Shape {
    // Doesn't implement area() or perimeter()
    // Adds its own abstract requirement
    abstract int numberOfSides();
}

class Triangle extends Polygon {
    // Must implement ALL three abstract methods
    double area() { /* implementation */ }
    double perimeter() { /* implementation */ }
    int numberOfSides() { return 3; }
}

Key Takeaway: Abstract subclasses can defer implementing inherited abstract methods, creating multi-level abstraction hierarchies where responsibility cascades downward until a concrete class completes the contract.