In a class diagram, which relationship best represents a 'Car' class having an 'Engine' class as a part of it, where the engine cannot exist without the car?
Think about whether the 'Engine' can exist independently of the 'Car'.
Composition means a strong ownership where the part (Engine) cannot exist without the whole (Car). Aggregation allows the part to exist independently.
A 'Library' class contains multiple 'Book' objects. Which multiplicity notation correctly represents this in a class diagram?
Consider how many books a library can have.
The library can have many books, so the multiplicity on the Book side is '*', meaning many.
You need to design a user management system that supports different user roles with specific permissions. Which class diagram design is best for scalability?
Think about flexibility and ease of adding new roles or permissions.
Using separate Role and Permission classes linked to User allows easy addition and management of roles and permissions without changing the User class.
Which statement best describes a tradeoff when choosing inheritance over composition in class diagrams?
Consider how easy it is to modify or extend behavior later.
Inheritance creates fixed class hierarchies that can be hard to change, while composition allows more flexible design by assembling behaviors.
For an online shopping system with features: user accounts, product catalog, shopping cart, order processing, payment, and reviews, estimate the minimum number of distinct classes needed in a well-designed class diagram.
Think about main entities and supporting classes for each feature.
A well-designed system would have classes like User, Product, Cart, CartItem, Order, Payment, Review, plus supporting classes, totaling around 10.