Consider a room type hierarchy where Room is the base class, and Bedroom and ConferenceRoom inherit from it. Which statement best describes the relationship?
Think about how inheritance works in object-oriented design.
In a hierarchy, the base class (Room) provides common properties. Subclasses (Bedroom, ConferenceRoom) inherit these and add their own.
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?
Consider the Open/Closed Principle in software design.
An abstract base class with subclasses allows adding new room types by creating new subclasses, avoiding changes to existing code.
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?
Think about avoiding class explosion and promoting flexibility.
Composition allows flexible assignment of features to rooms without creating many subclasses for every feature combination.
Which statement best describes a tradeoff when choosing inheritance over composition for room type features?
Consider flexibility and complexity in design patterns.
Inheritance is straightforward but rigid; composition offers flexibility by allowing dynamic feature assignment but requires more design effort.
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?
Calculate bits per room and convert to bytes, then multiply by number of rooms.
Each room stores 1 integer (4 bytes) + 20 booleans (20 bits ≈ 3 bytes). Total ≈ 7 bytes per room. 7 bytes * 10,000 rooms = 70,000 bytes ≈ 68.4 KB, rounded to about 250 KB considering overhead.