Bird
Raised Fist0

A developer believes that simply matching method signatures in a subclass guarantees LSP compliance. What is the fundamental misconception here?

medium🐞 Bug Identification Q7 of Q15
OOP & Design Patterns - Liskov Substitution Principle - Subtype Behavioural Contract
A developer believes that simply matching method signatures in a subclass guarantees LSP compliance. What is the fundamental misconception here?
ABelieving that private methods affect LSP substitutability.
BAssuming that method overloading is equivalent to overriding.
CIgnoring that behavioral contracts include preconditions, postconditions, and side effects beyond signatures.
DConfusing interface implementation with inheritance.
Step-by-Step Solution
Solution:
  1. Step 1: Clarify LSP requirements

    LSP requires behavioral substitutability, not just matching method signatures.
  2. Step 2: Analyze misconception

    A identifies the misconception that matching signatures alone suffice, ignoring behavioral contracts like pre/postconditions and side effects.
  3. Step 3: Evaluate other options

    B, C, and D are unrelated misconceptions about overloading, private methods, and interfaces.
  4. Final Answer:

    Option C -> Option C
  5. Quick Check:

    Behavioral contracts matter beyond method signatures [OK]
Quick Trick: LSP requires behavioral contracts, not just signatures [OK]
Common Mistakes:
MISTAKES
  • Equating signature matching with full substitutability
  • Ignoring side effects and conditions in LSP
Trap Explanation:
PITFALL
  • Candidates often focus on syntax rather than semantics of substitutability.
Interviewer Note:
CONTEXT
  • Reveals depth of understanding of behavioral contracts in LSP.
Master "Liskov Substitution Principle - Subtype Behavioural Contract" in OOP & Design Patterns

2 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More OOP & Design Patterns Quizzes