What is an abstract class in Java?
Why Interviewers Ask This
Interviewers use this question to quickly assess whether a candidate has the foundational knowledge required for Java development. It reveals whether you understand the building blocks that more complex concepts rely on.
Answer
An abstract class is a class declared with the abstract keyword that cannot be instantiated directly — you must create a concrete subclass that provides implementations for all abstract methods. Abstract classes can have a mix of abstract methods (declared without a body) and concrete methods (with a body). They can also have constructors, instance fields, and static members. Use abstract classes to define a common template for a family of related classes, providing shared implementation while forcing subclasses to implement specific behaviors. Example: an abstract Shape class with an abstract area() method, implemented differently by Circle, Rectangle, etc.
Common Mistake
Many candidates answer correctly but can't explain the 'why'. Always be prepared to justify your answer with a concrete example or use case from your Java experience.