Skip to content
We areTOP 1%

What is the difference between an abstract class and an interface?

EasyConceptOOP & SOLID
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

An abstract class is a partially implemented base class that can hold state, constructors and concrete methods, and a class can extend only one. An interface is a contract of methods that unrelated classes can implement, and a class can implement many.

  • Use an abstract class when subclasses share common state or code, such as a Vehicle with a licensePlate field and shared validation.
  • Use an interface to describe a capability, such as Comparable or Payable, across unrelated types.
  • Java detail: since Java 8, interfaces can have default and static methods, but they still cannot hold instance fields.
  • C++ has no interface keyword; an abstract class containing only pure virtual functions plays that role, and multiple inheritance is allowed.

More in OOP & SOLID

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account