Don’t Break the Duck – The Liskov Quiz
Is your subclass secretly a saboteur? Is that Rectangle actually a Square in disguise? 🟥🔺 Then this quiz is for you!
👨🏫 **Definition:** The Liskov Substitution Principle (LSP) says: *If S is a subtype of T, then objects of type T may be replaced with objects of type S without altering the correctness of the program.* In short, subclasses should behave like their parents — no family drama allowed! 😤
🦆 **Real-Life Examples:**
- If it walks like a duck and quacks like a duck, it shouldn't suddenly explode when you try to swim it.
- A **remote control** for all TVs should still work if you swap Sony with Samsung. If not, it's violating LSP.
- If your **electric car** suddenly refuses to drive because it doesn’t “feel like a car today,” it’s not following LSP, it's throwing tantrums.
🎯 In this quiz, you’ll:
- Spot sneaky subclasses that break parent promises
- Refactor shape classes that betray their inheritance
- Understand why behavior consistency beats code reuse
Perfect for catching those “it extends the class but acts wild” bugs. Time to tame your subclasses and earn your Black Belt in Object-Oriented Sorcery! 🧙♂️🖥️✨