Difference Between Abstract Class and Interface in Java

Last Updated : 16 May, 2026

Abstract classes and interfaces are used in Java to achieve abstraction and design flexible applications. They define a structure that other classes must follow, helping in code reusability and maintainability. While both serve similar purposes, they differ in implementation and usage.

  • Abstract class can have both abstract and normal methods, while interface mainly contains abstract methods.
  • A class can extend only one abstract class, but can implement multiple interfaces.
  • Abstract class can have constructors and variables, whereas interface contains only constants and no constructors.
abstract_class
Depiction of Abstract class and Interface

Abstract Class

An abstract class is a class that cannot be instantiated and is used as a base for other classes. It can contain both abstract (unimplemented) and concrete (implemented) methods.

  • Supports both abstract and non-abstract methods.
  • Allows constructors and instance variables.
Java
abstract class Shape {

    // Abstract method
    abstract double area();

    // Concrete method
    void display() {
        System.out.println("This is a shape");
    }
}

class Circle extends Shape {

    int radius = 5;

    // Implementing abstract method
    @Override
    double area() {
        return 3.14 * radius * radius;
    }
}

public class Main {
    public static void main(String[] args) {

        Shape shape = new Circle();  // Upcasting
        shape.display();
        System.out.println("Area of Circle: " + shape.area());
    }
}

Output
This is a shape
Area of Circle: 78.5

Explanation: Shape is an abstract class with an abstract method area() and a concrete method display(). Circle extends it and implements area(). Using Shape shape = new Circle(); shows upcasting, and calling shape.area() demonstrates runtime polymorphism.

Interface

An interface is a blueprint that defines a set of methods a class must implement. It focuses on behavior rather than implementation.

  • All methods are abstract by default (except default/static methods in Java 8+).
  • Supports multiple inheritance.
Java
// Interface
interface Drawable {
    void draw();
}

// Implementation class
class Rectangle implements Drawable {
    @Override
    public void draw() {
        System.out.println("Drawing Rectangle");
    }
}

// Main class
public class Main {
    public static void main(String[] args) {
        // Interface reference pointing to implementation object
        Drawable d = new Rectangle();
        d.draw();
    }
}

Output
Drawing Rectangle

Explanation: Drawable is an interface with method draw(). Rectangle implements it and defines the method. Drawable d = new Rectangle(); shows polymorphism, and d.draw() executes the Rectangle method at runtime.

Abstract Class vs Interface

FeatureAbstract ClassInterface
Default Method ImplementationCan have any number of fully defined methodsOnly default/static methods (Java 8+)
Method Access LevelMethods can be private, protected, or publicMethods are public by default (private allowed from Java 9)
Variable InitializationVariables can be initialized or uninitializedVariables must be initialized at declaration
Object BehaviorCan maintain state (instance variables)Cannot maintain state (only constants)
Inheritance TypeSupports single inheritanceSupports multiple inheritance
Implementation KeywordExtended using extendsImplemented using implements
Static MethodsCan have static methodsCan have static methods (Java 8+)
Final MethodsCan have final methods (cannot be overridden)Cannot have final methods
Main MethodCan have main methodCan also have main method (Java 8+)
Design PurposeFor code reuse and base class designFor defining contracts/behaviors
Tight vs Loose CouplingLeads to tighter couplingPromotes loose coupling
When to UseWhen classes are closely relatedWhen classes are unrelated but share behavior
Method OverridingOptional (only abstract methods must be overridden)Mandatory to implement all abstract methods
PerformanceSlightly better (less abstraction)Slightly more overhead
Keywords Usedabstract, extendsinterface, implements
Comment