Bird
Raised Fist0

Which of the following statements about using inheritance to model different vehicle types in the parking lot system is INCORRECT?

medium🐞 Bug Identification Q14 of Q15
OOP & Design Patterns - Design a Parking Lot - LLD with OOP (Classes, Patterns, Extensibility)
Which of the following statements about using inheritance to model different vehicle types in the parking lot system is INCORRECT?
AInheritance allows sharing common vehicle attributes and behaviors in a base Vehicle class
BUsing inheritance for vehicle types can lead to rigid designs that are hard to extend with new types
CInheritance is always the best approach to add new vehicle types without modifying existing code
DPolymorphism enables treating all vehicle types uniformly when allocating parking spots
Step-by-Step Solution
  1. Step 1: Review inheritance benefits

    Inheritance supports code reuse and polymorphism for uniform handling.
  2. Step 2: Recognize limitations

    Inheritance hierarchies can become rigid and hard to extend, violating open-closed principle.
  3. Step 3: Identify incorrect statement

    Claiming inheritance is always best ignores alternatives like composition or interfaces that improve extensibility.
  4. Final Answer:

    Option C -> Option C
  5. Quick Check:

    Inheritance is not always best for extensibility [OK]
Quick Trick: Inheritance can cause rigidity; prefer composition for extensibility [OK]
Common Mistakes:
MISTAKES
  • Assuming inheritance is always the best design choice
  • Ignoring polymorphism benefits
Trap Explanation:
PITFALL
  • Option D is tempting because inheritance is a common first approach, but it can cause maintenance issues.
Interviewer Note:
CONTEXT
  • Tests understanding of OOP principles and common design pitfalls
Master "Design a Parking Lot - LLD with OOP (Classes, Patterns, Extensibility)" 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