Bird
Raised Fist0

What is a key reason to separate room types into distinct classes with clear abstraction layers instead of placing all properties and methods in a single Room class?

hard🧠 Conceptual Q10 of Q15
LLD - Design — Hotel Booking System
What is a key reason to separate room types into distinct classes with clear abstraction layers instead of placing all properties and methods in a single Room class?
ATo improve code modularity and allow easier extension of new room types
BTo reduce the number of classes and simplify the codebase
CTo ensure all rooms share exactly the same features and behaviors
DTo avoid using inheritance and polymorphism
Step-by-Step Solution
Solution:
  1. Step 1: Understand Abstraction Layers

    Separating room types into classes allows encapsulating specific features and behaviors.
  2. Step 2: Benefits of Modularity

    This modularity makes the system easier to maintain and extend with new room types without affecting existing code.
  3. Final Answer:

    To improve code modularity and allow easier extension of new room types -> Option A
  4. Quick Check:

    Modularity enables scalable and maintainable design [OK]
Quick Trick: Clear abstractions enable flexible, maintainable code [OK]
Common Mistakes:
MISTAKES
  • Thinking fewer classes always means simpler code
  • Assuming all rooms must be identical
  • Avoiding inheritance reduces flexibility

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes