Course contentsShow
← Java
Lesson 532 of 2,87012. Abstract Classes and InterfacesFree lesson

Decision Criteria: A Practical Checklist

A step-by-step guide to choosing between abstract classes and interfaces based on inheritance, state, and API stability.

Decision Criteria: A Practical Checklist

What you'll learn: A practical, step-by-step checklist to confidently choose between abstract classes and interfaces in your Java designs.

After learning the differences between abstract classes and interfaces, you need a decision framework. Here's your go-to checklist:

The Checklist

Choose an Abstract Class when:

  1. You need shared state — Multiple subclasses require common fields or instance variables
  2. Constructors are necessary — You need to initialize common state when objects are created
  3. You want to provide substantial shared implementation — Multiple concrete methods with shared logic
  4. Strict is-a relationship — A clear inheritance hierarchy exists (e.g., Vehicle → Car)
  5. Future evolution is private — You control all subclasses and can modify freely

Choose an Interface when:

  1. No shared state needed — You're defining a pure contract of capabilities
  2. Multiple inheritance required — A class must fulfill multiple contracts (e.g., Comparable + Serializable)
  3. Unrelated classes should share behavior — Types from different hierarchies need the same contract
  4. Public API stability matters — You're designing a library where backward compatibility is critical (use default methods for evolution)
  5. Marker behavior — You need a type flag with no methods at all

The Hybrid Approach

Remember: You can combine both! An abstract class can implement one or more interfaces, giving you:

  • The shared state and constructors from the abstract class
  • The multiple contract capabilities from interfaces
  • Maximum flexibility

Quick Decision Tree

Ask yourself: "Do I need shared state or constructors?" → Yes = Abstract class, No = Interface

Then ask: "Does this need multiple inheritance?" → Yes = Must use interface

Key Takeaway: Choose abstract classes for is-a relationships with shared state and constructors; choose interfaces for contracts, multiple inheritance, and API stability. When in doubt, prefer interfaces for flexibility.