0
0
LLDsystem_design~20 mins

Room type hierarchy in LLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Room Type Hierarchy Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding inheritance in room type hierarchy

Consider a room type hierarchy where Room is the base class, and Bedroom and ConferenceRoom inherit from it. Which statement best describes the relationship?

ARoom inherits properties from Bedroom and ConferenceRoom.
BBedroom and ConferenceRoom are unrelated to Room and do not share any properties.
CBedroom and ConferenceRoom share common properties from Room and add their own specific features.
DRoom is a subtype of Bedroom and ConferenceRoom.
Attempts:
2 left
💡 Hint

Think about how inheritance works in object-oriented design.

Architecture
intermediate
2:00remaining
Designing a scalable room type hierarchy

You need to design a system to manage different room types in a hotel. Which design choice best supports adding new room types without changing existing code?

AUse an abstract Room class with subclasses for each room type implementing specific behaviors.
BCreate a single Room class with many conditional statements to handle all room types.
CDuplicate code for each room type in separate classes without inheritance.
DUse global variables to store room type information and behaviors.
Attempts:
2 left
💡 Hint

Consider the Open/Closed Principle in software design.

scaling
advanced
2:30remaining
Handling multiple room features in hierarchy

In a hotel system, rooms can have multiple features like 'hasProjector', 'hasBalcony', or 'isSoundproof'. What is the best way to design the room type hierarchy to handle these features efficiently?

ACreate a subclass for every combination of features (e.g., BalconyConferenceRoom).
BAdd all possible features as boolean fields in the base Room class.
CIgnore features and handle them only in the booking system.
DUse composition by creating feature classes and assign them to rooms instead of deep inheritance.
Attempts:
2 left
💡 Hint

Think about avoiding class explosion and promoting flexibility.

tradeoff
advanced
2:00remaining
Tradeoffs between inheritance and composition in room types

Which statement best describes a tradeoff when choosing inheritance over composition for room type features?

AInheritance always uses less memory than composition.
BInheritance is simpler but less flexible; composition is more flexible but can be more complex to implement.
CComposition cannot represent shared behavior, inheritance can only represent shared data.
DInheritance allows dynamic feature changes at runtime, composition does not.
Attempts:
2 left
💡 Hint

Consider flexibility and complexity in design patterns.

estimation
expert
3:00remaining
Estimating storage needs for room type hierarchy

A hotel has 10,000 rooms with 5 main room types and 20 optional features. Each room stores its type and features. If each feature is stored as a boolean and the room type as an integer, approximately how much storage is needed to store all room type and feature data for all rooms?

AAbout 250 KB
BAbout 2.5 MB
CAbout 25 MB
DAbout 250 MB
Attempts:
2 left
💡 Hint

Calculate bits per room and convert to bytes, then multiply by number of rooms.