Abstract Class vs Interface in Java
Fast recall
Quick revision
Core answer
OOP design judgment — not just a syntax list, but knowing which abstraction to reach for when modelling a real domain
Listing syntax differences only (no fields in interface, abstract class can't be multiply extended) without mentioning Java 8 default methods or giving a design example
Explain how Java 8 default methods blurred the line, why abstract class still wins when you need shared mutable state or a constructor, and give a concrete example like a template method pattern
Interview-ready guide
Interview answer
In Java, both abstract classes and interfaces let you define behavior that subclasses or implementing classes must provide — but they serve different design intents. An abstract class defines what something IS, supporting shared state and partial implementation. An interface defines what something CAN DO, as a pure contract that any class can fulfill regardless of its inheritance hierarchy.
Abstract class — IS-A, shared state
- Can hold instance fields, constructors, and methods with any access modifier
- Use when subclasses share mutable state (a counter, a timestamp) or initialization logic
- Template method pattern: parent defines the algorithm skeleton, children override specific steps
Interface — CAN-DO, pure contract
- No instance fields (only
public static finalconstants) - A class can implement many interfaces but extend only one class — interfaces compose; abstract classes don't
Comparable,Serializable,Runnabledescribe capabilities, not identity
How Java 8 changed the picture
- Default methods let interfaces carry method bodies — the decision is no longer "do I need implementations?"
- The real question: do you need shared mutable state or a constructor? If yes → abstract class
- Adding a
defaultmethod to an interface is backward-compatible; adding anabstractmethod to an abstract class breaks every existing subclass
I recommend reaching for an interface first; add an abstract class only when state or constructor logic is genuinely needed.
Abstract Class vs Interface in Java
Direct Answer
An interface defines a contract (what an object can do) and supports multiple inheritance; it can carry default and static method implementations since Java 8. An abstract class provides a partial base implementation (what an object is) and can hold state, constructors, and access-modifier-varied members. Choose interface for capabilities; abstract class for shared implementation.
Common Mistakes & Pitfalls
Listing syntax differences only (no fields in interface, abstract class can't be multiply extended) without mentioning Java 8 default methods or giving a design example
Check your understanding
Answer these without looking back at the article.
- Can an interface extend another interface?
- What happens when a class implements two interfaces with the same default method?
- What is the template method design pattern and when does it need an abstract class?
Related interview prep categories
1Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.