Back to Lessons

Abstraction with Abstract Classes

April 5, 2026

Abstraction

Hiding implementation details, showing only essentials.

Abstract Class Example

abstract class Shape {
    abstract double calculateArea();
    
    void display() { // Concrete method
        System.out.println("Shape details");
    }
}

class Circle extends Shape {
    double radius;
    
    double calculateArea() {
        return Math.PI * radius * radius;
    }
}

Key Points

  • abstract classes cannot be instantiated.
  • Abstract methods have no body.
  • Concrete classes extend abstract classes.
  • Provides partial implementation.