Chapter 19: Problem 8
A classic Liskov substitution principle example consists of two classes, Square and Rectangle. Since a square is-a rectangle, the relationship between the two can be modeled using inheritance, with \(S q\) uare deriving from Rectangle. Suppose that Rectangle has methods to set/get the width, and set/get the length. Explain how this relationship between Square and Rectangle violates the Liskov substitution principle.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.