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 boat’s speed against the stream is 66.67% less than its speed in still water. If it covers 180 km downstream in 4 hours, find the time (in minutes) ...
Find the total distance covered by boat in each upstream and downstream in 8 hours if the speed of boat in still water and speed of current is 26 km/h a...
A man rows to a place 24 km distant and comes back in 14 hours. He finds that he can row 4 km with the stream at the same time as 3 km against the strea...
The boat's speed in still water is 20% greater than the speed of the stream. If it takes the boat 4 hours more to travel 176 km d...
If a boat travels 35 km more in downstream than in upstream in 5 hr and if the speed of the boat in still water is 25 km/hr, then find the distance trav...
If the sum of upstream and downstream speed is 20 km/hr and the speed of the current is 5 km/hr. Then find time taken to cover 45 km in downward?
If a man rows at the rate of 17 kmph in still water and his rate against the current is 7 kmph, then find the man’s speed with downstream....
Speed of the boat in still water and the downstream speed of the boat are in the ratio of 5:6 respectively. The boat covers 80 km upstream and 72 km dow...
A boat can cover 120 km in upstream in 6 hours and 180 km in downstream in 3 hours. Find the speed of the stream.
Ratio of speed of boat in downstream and speed of stream is 7:5, if speed of current is 5 km/hr, then find distance travelled (in km) upstream in 4 hours.