Q13: What are the differences between an Abstract Class and an Interface?

FeatureAbstract ClassInterface (Java 8+)
InheritanceSingle class inheritance (extends)Multiple interface implementation (implements)
StateCan hold state (private instance fields)Stateless (only public static final constants)
ConstructorsSupportedNot supported
MethodsAbstract, concrete, protected, private methodsabstract, default, static, and private (Java 9+) methods
Key Takeaways
  • Use Abstract Classes for sharing state and identity in class hierarchies.
  • Use Interfaces for defining peripheral behavioral capability contracts across unrelated hierarchies.
Knowledge Check

Can a class extend multiple abstract classes in Java?