OOP Concepts Easy technical 0 views 1 min read

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

Peer-reviewed by HireXTech Technical Panel • Updated for 2025/2026 hiring • Editorial standards
Practise this track
Interviewer Expectations for this Question
01
Core Competency

Assesses fundamental understanding of OOP Concepts conventions, runtime behavior, and memory/performance considerations.

02
Evaluation Criteria

Hiring managers look for precision, avoidance of ambiguous jargon, and ability to explain trade-offs under real production conditions.

Comprehensive Model Answer Verified Solution

An interface declares a contract: a set of method signatures with no state that any type can implement. A class can implement many interfaces, which models capability. An abstract class is a partially implemented base class that can hold fields, constructors and concrete methods; a class can extend only one.

interface Flyer { void fly(); }
abstract class Bird {
    protected String name;
    Bird(String name) { this.name = name; }
    abstract void sing();
    void sleep() { System.out.println("sleeping"); }
}

Use an interface when unrelated types must share a capability and when you want multiple inheritance of type. Use an abstract class when related types share code and state, and you want to force subclasses to fill in specific steps. Many designs use both: an abstract class implements a primary interface and provides default behaviour, while callers depend only on the interface. Prefer interfaces at module boundaries and abstract classes internally.

Candidate Response Strategy & Interview Tips

  1. Start with a concise one-sentence summary: Deliver a direct, confident answer first before expanding into nuances.
  2. Demonstrate real-world trade-offs: Discuss where this approach excels and when you would avoid it in production systems.
  3. Discuss complexity & edge cases: Proactively explain time/space complexity or boundary conditions (null values, scale limits).
  4. Prepare for interviewer follow-ups: Technical hiring panels frequently probe deeper into concurrency, backward compatibility, or alternative libraries.
Related Topics & Skills
Spotted an error or have an alternative solution?