Intermediate Object-Oriented Programming Concepts
Q79 / 100

When designing class hierarchies, why is "is-a" sometimes a misleading guide for inheritance (e.g. "a Square is-a Rectangle")?

Correct! Well done.

Incorrect.

The correct answer is A) Because subclassing must always preserve behavioral expectations (LSP); a Square subclassing Rectangle can violate invariants if width/height are independently settable

A

Correct Answer

Because subclassing must always preserve behavioral expectations (LSP); a Square subclassing Rectangle can violate invariants if width/height are independently settable

Explanation

The classic Square/Rectangle example shows that a conceptual "is-a" relationship can break the Liskov Substitution Principle if the subclass cannot honor all behaviors expected of the parent.

Progress
79/100