Free tutorials in Hindi & English Daily computer, mobile and IT guides Beginner friendly learning
Blog · Java · 04 Jul 2026 · Hindi + English

Abstract Class vs Interface in Java (After Java 8)

Abstract class = partial implementation + state; interface = contract with multiple inheritance. Updated for Java 8 default methods, with decision table.

The one-line answer

An abstract class is a partially-built class (can have state + implemented methods) that a child extends; an interface is a pure contract (what to do, not how) that a class implements — and a class can implement many interfaces but extend only one class.

Code: both in action

abstract class Vehicle {                 // abstract class
    int wheels = 4;                       // state allowed
    void start() {                        // implemented method allowed
        System.out.println("Starting...");
    }
    abstract void drive();                // abstract: child MUST implement
}

interface GPS {                           // interface
    void navigate(String to);             // implicitly public abstract
}

class Car extends Vehicle implements GPS {   // extends 1 + implements many
    void drive() { System.out.println("Car driving"); }
    public void navigate(String to) { System.out.println("Going to " + to); }
}

Car c = new Car();
c.start(); c.drive(); c.navigate("Aligarh");
Starting... Car driving Going to Aligarh

Comparison table (updated for Java 8+)

PointAbstract classInterface
Keywordextendsimplements
Multiple inheritance❌ Only one✅ Many interfaces
Instance variables✅ Any kind❌ Only public static final constants
Constructors✅ Yes (called via super)❌ Never
Method bodies✅ Normal methodsOnly default/static methods (Java 8+)
Access modifiersAny (private, protected...)Methods implicitly public

The Java 8 twist interviewers now ask

interface GPS {
    void navigate(String to);
    default void recalculate() {              // Java 8: body in interface!
        System.out.println("Recalculating route...");
    }
}
Since Java 8, interfaces can have default and static methods with bodies — so "interface has no implementation" is an outdated answer. The remaining real differences: abstract classes have state (instance variables) and constructors; interfaces do not. Say this and you stand out.

When to use which (decision rule)

  • Abstract class — related classes sharing code and fields: Vehicle → Car, Bike, Truck (all share wheels, engine logic). An "is-a with shared machinery" relationship.
  • Interface — a capability that unrelated classes can have: Comparable, Runnable, GPS. A "can-do" contract.
  • Interview line: "Abstract class for shared identity and code; interface for shared capability."

One-line answer

Abstract class एक अधूरी बनी class है (state + implemented methods रख सकती है) जिसे child extends करता है; interface एक pure contract है (क्या करना है, कैसे नहीं) जिसे class implements करती है — और class कई interfaces implement कर सकती है लेकिन extend सिर्फ एक class.

Code: दोनों action में

abstract class Vehicle {                 // abstract class
    int wheels = 4;                       // state allowed
    void start() {                        // implemented method allowed
        System.out.println("Starting...");
    }
    abstract void drive();                // abstract: child को ZAROOR बनाना है
}

interface GPS {                           // interface
    void navigate(String to);             // implicitly public abstract
}

class Car extends Vehicle implements GPS {   // extends 1 + implements कई
    void drive() { System.out.println("Car driving"); }
    public void navigate(String to) { System.out.println("Going to " + to); }
}

Car c = new Car();
c.start(); c.drive(); c.navigate("Aligarh");
Starting... Car driving Going to Aligarh

Comparison table (Java 8+ के लिए updated)

PointAbstract classInterface
Keywordextendsimplements
Multiple inheritance❌ सिर्फ एक✅ कई interfaces
Instance variables✅ किसी भी तरह के❌ सिर्फ public static final constants
Constructors✅ हां (super से call)❌ कभी नहीं
Method bodies✅ Normal methodsसिर्फ default/static methods (Java 8+)
Access modifiersकोई भी (private, protected...)Methods implicitly public

Java 8 twist जो interviewers अब पूछते हैं

interface GPS {
    void navigate(String to);
    default void recalculate() {              // Java 8: interface में body!
        System.out.println("Recalculating route...");
    }
}
Java 8 से interfaces में body वाले default और static methods हो सकते हैं — इसलिए "interface में implementation नहीं होती" पुराना answer है. बचे हुए असली अंतर: abstract classes में state (instance variables) और constructors होते हैं; interfaces में नहीं. यह बोलेंगे तो अलग दिखेंगे.

कब कौन-सा use करें (decision rule)

  • Abstract class — code और fields share करने वाली related classes: Vehicle → Car, Bike, Truck (सब wheels, engine logic share करते हैं). "is-a with shared machinery" relationship.
  • Interface — ऐसी capability जो unrelated classes में हो सकती है: Comparable, Runnable, GPS. एक "can-do" contract.
  • Interview line: "Shared identity और code के लिए abstract class; shared capability के लिए interface."

Frequently Asked Questions

What is the main difference between abstract class and interface?

An abstract class can hold state (instance variables), constructors and implemented methods and supports single inheritance, while an interface is a contract supporting multiple inheritance with only constants and (since Java 8) default/static method bodies.

Can an interface have method bodies?

Since Java 8, yes — default and static methods in an interface can have bodies. Regular interface methods remain abstract.

Why can a class implement multiple interfaces but extend only one class?

Multiple class inheritance creates the diamond problem with conflicting state; interfaces carry no instance state, so implementing many of them stays unambiguous.