Design Patterns · Junior · Question 28 of 75
What does the Liskov Substitution Principle (LSP) require?
- ✓Correct answer: A subtype must be usable anywhere the base type is expected
- 2A subclass must override all of the parent's methods
- 3You can't inherit more than two levels deep
Explanation
The classic violation: Square extends Rectangle, where setWidth also changes the height - code that relies on a rectangle breaks. On the frontend: a wrapper component around <input> should support expected props like onChange and disabled.