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.
What is the maximum number of rectangles in the given figure?
How many triangles are there in the given figure?
Rekha starts from her house and goes 3 km straight. Then she turns towards her left and goes 1 km. She again turns towards her left and goes 2 km. If sh...
statement:
Residents of this region are frequently faced with incidents of sudden power surges and voltage surges which cause damage to sensitive...
Three statements are given, followed by three conclusions numbered I, II and III.
Assuming the statements to be true, even if they seem to be a...
In this question, three statements are given, followed by three conclusions numbered I, II and III. Assuming the statements to be true, even if they see...
Four pairs of letter-clusters have been given, out of which three are alike in some manner and one is different. Select the one that is different.
In the following question, select the missing number from the given series.
?, 3, 5, 7, 11, 13

Select the option that is related to the third word in the same way as the second word is related to the first word.
Lazy : Hard-working : : Wealthy : ?