Bird
Raised Fist0

When designing a framework that enforces LSP, what is a potential downside of using runtime checks to validate behavioral contracts?

medium🪤 Complexity Trap Q6 of Q15
OOP & Design Patterns - Liskov Substitution Principle - Subtype Behavioural Contract
When designing a framework that enforces LSP, what is a potential downside of using runtime checks to validate behavioral contracts?
AIt simplifies subclass implementations by removing the need for careful design.
BIt guarantees all contract violations are prevented before deployment.
CIt introduces performance overhead and may fail to catch all contract violations at compile time.
DIt eliminates the need for unit testing subclasses.
Step-by-Step Solution
Solution:
  1. Step 1: Understand runtime contract enforcement

    Runtime checks can detect violations but add overhead and cannot replace compile-time guarantees.
  2. Step 2: Analyze options

    A correctly identifies performance cost and incomplete coverage at compile time. B is false; runtime checks do not guarantee prevention before deployment. C and D are false; runtime checks do not simplify design or replace testing.
  3. Final Answer:

    Option C -> Option C
  4. Quick Check:

    Runtime checks add overhead and lack compile-time guarantees [OK]
Quick Trick: Runtime checks add overhead and miss compile-time errors [OK]
Common Mistakes:
MISTAKES
  • Believing runtime checks guarantee full contract safety
  • Assuming runtime checks reduce design/testing effort
Trap Explanation:
PITFALL
  • Candidates overestimate runtime checks as a substitute for design discipline and testing.
Interviewer Note:
CONTEXT
  • Tests awareness of practical limitations in enforcing LSP dynamically.
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