Interface vs Abstract Class in Java — When to Use Each
An interface defines a contract any class can implement; an abstract class provides shared state and partial implementation for related subclasses.
Published September 22, 2026
An interface defines a contract of methods a class agrees to implement, and a class can implement multiple interfaces. An abstract class can hold shared fields, constructors, and partially implemented methods, but a class can only extend one abstract class.
Common causes
- Java doesn't support multiple inheritance of state (to avoid the ambiguity problems it can cause), so interfaces exist to let a type participate in multiple unrelated contracts without that ambiguity
How to fix it
- Use an interface when you're defining a capability unrelated classes might share, like Comparable or Serializable, especially when multiple inheritance of the contract is needed
- Use an abstract class when subclasses share common state or behavior that shouldn't be duplicated, and the relationship between them is a genuine 'is-a' hierarchy
- Since Java 8, interfaces can include default methods with implementations, blurring the line somewhat — but interfaces still cannot hold instance state (fields) the way abstract classes can
Example
interface Shape {
double area();
}
abstract class Animal {
protected String name;
abstract void makeSound();
}FAQ
Can an abstract class implement an interface?
Yes — and it can leave some of the interface's methods unimplemented, deferring them to its own concrete subclasses, since the abstract class itself is never instantiated directly.