Q32. What is an abstract class?
An abstract class cannot be instantiated directly and can declare abstract members that subclasses must implement. It may also provide shared implementation. Use it when a base abstraction genuinely shares behavior; interfaces are often better for pure contracts.
A subclass must implement inherited abstract members before it can be instantiated as a concrete class.
Note
Interview approach: define the concept, explain why it matters, then mention one trade-off or limitation.
TypeScript concept
// Illustrative TypeScript contract
type Identifier = string;
const id: Identifier = "item-1";💡 The example demonstrates the compile-time contract discussed in this question.
Key Takeaways
- Explain the concept in your own words.
- Know the practical trade-off and its limits.
- Use a small example to demonstrate the idea.
Knowledge Check
Can a non-abstract subclass omit an inherited abstract method?