Question
Which type of relationship between classes in OOP is
best represented when one class is a part of another class but can exist independently?Solution
Aggregation is a type of association that represents a "whole-part" relationship between two classes. The key characteristic is that the part (child object) can exist independently of the whole (parent object). For instance, in a Team class and Player class, a Player can exist without being associated with a Team . Aggregation is implemented by using references, where one class has an attribute referencing another class. This design principle promotes flexibility and modularity. Aggregation is often represented with a hollow diamond in UML diagrams. Why Other Options Are Wrong Option B : "Inheritance" Inheritance represents an "is-a" relationship, not a "whole-part" relationship. It is used to share functionality between classes, not to model part-whole dependencies. Option C : "Composition" Composition is similar to aggregation but with a crucial difference: the part cannot exist independently of the whole. For example, a Car and its Engine share a composition relationship because an engine has no meaning outside the car. Option D : "Association" Association is a broader concept that describes any relationship between classes. Aggregation is a specific type of association. Option E : "Polymorphism" Polymorphism is unrelated to class relationships and focuses on method behavior.
A person rows x km downstream and the same distance upstream in 10 hours. He can row 2x km downstream in 5 hours. What is the time taken to row x km ups...
A boat, whose speed in still water is 25% more than the speed of the current, covers 810 km downstream in _____ hours. The speed of the boat in still wa...
Speed of a boat in still water is 6 times more than the speed of stream. If boat covers 112 km in downstream in 8 hours, then find the time taken by the...
Boat βAβ can cover 160 km in still water in 8 hours. In still water, if the ratio of the speed of boat βAβ to that of βBβ is 4:3 and the spe...
The duration needed to travel (x β 36) km upstream equals the time taken to go (2x β 72) km downstream. If the boatβs speed is 10.5 km/h and the c...
The ratio of the speed of boat βAβ in still water, the speed of boat βBβ in still water and the speed of the current is 11:5:2, respectively. If...
A man can go on a motorboat with a speed of 12 km/hour in still water to a certain upstream point and return to the starting point in a river that flows...
A boat travels 48 km downstream in 4 hours and 24 km upstream in 6 hours. What is the speed of the boat in still water?
A man can swim downstream in 12 minutes covering a distance of 600 meters. He takes 15 minutes to cover the same distance upstream. Find the speed of th...
A boat takes 1/12th time in moving a certain distance downstream than upstream. The ratio of the speed of the boat in still water and that of the curren...