Multiple ChoiceHard 45s
LSP violations in practice
A ReadOnlyCollection subtype throws UnsupportedOperationException on add() inherited from MutableCollection. Which principle is violated?
Options
- 1Liskov Substitution Principle: the subtype cannot stand in for its supertype without breaking callers
- 2Open/Closed Principle: the class is closed for extension because new operations cannot be added
- 3Interface Segregation Principle: the interface declares too few methods for the callers that use it
- 4Dependency Inversion Principle: high-level policy code imports a low-level mutable collection detail
Think you can answer under pressure?
Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.