Chaturmind
LearnDSASystem DesignDevOpsEngineering GrowthBlog
Start learning
Chaturmind

Structured learning paths for engineers who want to go deep. Written by practitioners.

Learn

  • Java
  • DSA
  • System Design
  • Spring Boot
  • AI / ML
  • DevOps
  • Engineering Growth

Company

  • Blog
  • Contact

Legal

  • Privacy Policy
  • Terms of Service

© 2026 Chaturmind. All rights reserved.

Built for engineers who want to go deep.


← Java Core Fundamentals

Object-Oriented Programming

  • Classes and Objects
  • Inheritance and Polymorphism
  • Interfaces and Abstract Classes

Collections Framework

  • List, Set, and Map
  • Generics
  • Collections Framework Recap
  • HashMap Deep Dive
  • TreeMap & LinkedHashMap
  • Iterators & Modification Semantics

Exceptions & Best Practices

  • Exception Handling
  • equals() and hashCode()
  • String Manipulation

JVM Internals & Memory Management

  • JVM Memory Areas
  • Garbage Collection Fundamentals
  • Modern Garbage Collectors
  • Memory Leaks in Java
  • GC Tuning & Diagnostics
Chaturmind
← Java Core Fundamentals

Object-Oriented Programming

  • Classes and Objects
  • Inheritance and Polymorphism
  • Interfaces and Abstract Classes

Collections Framework

  • List, Set, and Map
  • Generics
  • Collections Framework Recap
  • HashMap Deep Dive
  • TreeMap & LinkedHashMap
  • Iterators & Modification Semantics

Exceptions & Best Practices

  • Exception Handling
  • equals() and hashCode()
  • String Manipulation

JVM Internals & Memory Management

  • JVM Memory Areas
  • Garbage Collection Fundamentals
  • Modern Garbage Collectors
  • Memory Leaks in Java
  • GC Tuning & Diagnostics
HomeLearnJavaJava Core FundamentalsObject-Oriented Programming
✓ FreeIntermediate· 10 min read

Interfaces and Abstract Classes

Design flexible contracts with interfaces and share logic with abstract classes.

Published September 21, 2026


Interfaces and Abstract Classes

Both define contracts that subclasses/implementors must fulfil — but they serve different purposes.

Interface — the contract

public interface Payable {
    void pay(double amount);         // abstract (must implement)
    String getReceipt();             // abstract

    default String currency() {      // default method — optional override
        return "USD";
    }
}
  • All methods are implicitly public
  • No instance state (only static final constants)
  • A class can implement multiple interfaces
  • Java 8+: default methods allow behaviour in interfaces

Abstract Class — the partial implementation

public abstract class Shape {
    private String color;           // instance state — allowed!

    public Shape(String color) { this.color = color; }

    public abstract double area();  // subclasses must implement

    public String describe() {       // shared behaviour
        return color + " shape with area " + area();
    }
}

public class Circle extends Shape {
    private double radius;
    public Circle(String color, double radius) { super(color); this.radius = radius; }

    @Override
    public double area() { return Math.PI * radius * radius; }
}

When to use which?

InterfaceAbstract Class
StateNoYes
Multiple inheritanceYesNo (single)
ConstructorNoYes
Use whenDefining a capabilitySharing implementation

Interview Tip

"Favour interfaces over abstract classes when you only need to define a contract. Abstract classes shine when you want to share code among closely related classes."

In Java 8+, interfaces are more powerful than ever (default methods). The distinction has blurred, but abstract classes still win when you need shared mutable state.

Previous

Inheritance and Polymorphism

Next

List, Set, and Map

AI Tutor

Lesson: Interfaces and Abstract Classes

Quick actions

AI responses can be inaccurate. Verify critical information.