midOOP
What is the Liskov Substitution Principle (LSP)?
Updated May 17, 2026
Short answer
LSP states that subclasses should be replaceable for their parent classes without breaking behavior.
Deep explanation
LSP ensures that derived classes extend base classes without changing expected behavior. Violating LSP leads to fragile inheritance hierarchies and runtime errors. It enforces behavioral compatibility, not just structural inheritance.
Real-world example
If a system expects a Bird, replacing it with Penguin should not break assumptions like flying capability.
Common mistakes
- Forcing inheritance where behavior is not fully compatible.
Follow-up questions
- What happens when LSP is violated?
- How does LSP relate to polymorphism?