Design Patterns · Middle · Question 19 of 75

Which of these situations violates the Liskov Substitution Principle?

Explanation

Code working with the base type doesn't expect an exception - substitution breaks the program. It's usually a sign that the hierarchy is wrong and the interface should be split (ISP). LSP doesn't forbid adding new methods.

Further reading

Problem with a question

Design Patterns · Middle · question 19

Test yourself

Take the Design Patterns · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz