Compare abstract classes and interfaces in modern Java (8+). When would you choose each?
Show the explanation
| Abstract class | Interface | |
|---|---|---|
| Inheritance | a class extends one | a class implements many |
| State | instance fields of any kind | only public static final constants |
| Constructors | yes (run by subclasses via super) | no |
| Methods | abstract and concrete, any access | abstract, default, static, private (Java 9+) |
| Relationship | "is a kind of" with shared code | "can do" — a capability or contract |
interface Payable { double amountDue(); } // capability
abstract class Employee implements Payable {
protected final String name; // shared state
Employee(String name) { this.name = name; }
public abstract double monthlyPay();
public double amountDue() { return monthlyPay(); } // shared behaviour
}
class Intern extends Employee {
Intern(String n) { super(n); }
public double monthlyPay() { return 15000; }
}Choose an interface to define a contract that unrelated classes can share (and to allow multiple inheritance of type). Choose an abstract class when closely related classes share state or a common partial implementation. A common design is both: an interface for the contract and an abstract class as a convenient base.
Original UniCircle question. Last reviewed 22 Oct 2026.
