Abstract Class vs Interface in Java 8+ — Complete Comparison with Decision Rules
Fast recall
Quick revision
Core answer
extends). Interface = pure contract, with default and static methods since Java 8 and private helpers since Java 9. Supports public constants only (no instance state), no constructors, a class can implement many interfaces. Decision rule: use an interface to declare a capability (Comparable, Flyable, Serializable); use an abstract class when you have shared state or protected infrastructure for a family of related types (e.g., AbstractList, HttpServlet).Whether the candidate understands the post-Java 8 landscape — default and static methods narrowed the gap — and still knows the remaining differences: state, constructors, access modifiers, inheritance count
Claiming interfaces can't have method bodies (pre-Java 8 thinking). Forgetting that interfaces have no instance state. Not knowing about private interface methods (Java 9)
Show the decision framework — capability vs family — and explain why JDK uses both (List interface + AbstractList skeletal implementation). Mention that Java 14+ sealed interfaces change the picture again
Interview-ready guide
Interview answer
After Java 8, the line between them moved — interfaces got default, static, and (since Java 9) private methods, so the real differences come down to state and inheritance.
What still only abstract classes can do
- Hold instance fields and mutable state
- Define constructors that run initialization logic
- Use
protectedand package-private access on members - Mark methods
finalto lock them down
What only interfaces can do
- Be implemented by many types from unrelated hierarchies (
implements A, B, C) - Be added to a type retroactively without disrupting its single-inheritance chain
- Evolve safely via
defaultmethods without breaking existing implementors
The decision framework
- Interface = capability that can apply to unrelated types (
Comparable,AutoCloseable,Flyable) - Abstract class = family of related types that share state and protected infrastructure (
AbstractList,HttpServlet) - The JDK pattern uses both together —
Listinterface +AbstractListskeletal implementation
Sealed interfaces (Java 17+)
- Restrict which types implement an interface —
sealed interface Event permits UserCreated, UserDeleted - Enables exhaustive
switchexpressions; narrows the abstract class niche further
Recommendation: Default to interfaces for declaring contracts — they're more flexible and safer to evolve. Reach for an abstract class when multiple concrete types will share state or protected setup logic, and consider combining them (JDK pattern) when you want to offer both a clean contract and a convenience skeleton.
Abstract Class vs Interface in Java 8+ — Complete Comparison with Decision Rules
Direct Answer
Abstract class = partial implementation + state. Supports instance fields, constructors, protected/package-private members, single inheritance only (extends). Interface = pure contract, with default and static methods since Java 8 and private helpers since Java 9. Supports public constants only (no instance state), no constructors, a class can implement many interfaces. Decision rule: use an interface to declare a capability (Comparable, Flyable, Serializable); use an abstract class when you have shared state or protected infrastructure for a family of related types (e.g., AbstractList, HttpServlet).
Common Mistakes & Pitfalls
Claiming interfaces can't have method bodies (pre-Java 8 thinking). Forgetting that interfaces have no instance state. Not knowing about private interface methods (Java 9)
Check your understanding
Answer these without looking back at the article.
- Can an abstract class have no abstract methods? If yes, why would you declare it abstract?
- Why can interfaces have `static` methods but not instance fields?
- How do `default` methods interact with the diamond problem in Java 8+?
- What does `sealed interface` add in Java 17+ that a regular interface can't express?
- In Spring, why is the `JpaRepository` an interface even though it has behavior?
Related interview prep categories
1Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.