What is the difference between an interface and an abstract class?
Assesses fundamental understanding of Java conventions, runtime behavior, and memory/performance considerations.
Hiring managers look for precision, avoidance of ambiguous jargon, and ability to explain trade-offs under real production conditions.
- An interface declares a contract. It supports abstract methods plus default and static methods (Java 8+), private methods (Java 9+) and constants. A class can implement many interfaces.
- An abstract class is a partially implemented base class. It can hold state (fields), constructors and any mix of abstract and concrete methods. A class extends only one.
Choose an interface to define capabilities across unrelated types and to keep inheritance flexible. Choose an abstract class to share implementation and state among closely related subclasses.
Candidate Response Strategy & Interview Tips
- Start with a concise one-sentence summary: Deliver a direct, confident answer first before expanding into nuances.
- Demonstrate real-world trade-offs: Discuss where this approach excels and when you would avoid it in production systems.
- Discuss complexity & edge cases: Proactively explain time/space complexity or boundary conditions (null values, scale limits).
- Prepare for interviewer follow-ups: Technical hiring panels frequently probe deeper into concurrency, backward compatibility, or alternative libraries.