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.
In which country does the Government-to-business Public eProcurement center called GeBIZ operate, where suppliers can engage in electronic commerce with...
The National Stock of India (NSE), has signed a tri-partite MoU with the Higher and Technical Education Department (HTED), _______ government, and Money...
In which Indian state was the discovery of the new species of cicada, named "Butterfly Cicadas," made?
What percentage of UPI transaction volume is attributed to PhonePe, according to RBI analysis?
Who is the CMD of REC Ltd.?
What is the revised limit for collateral-free agricultural loans announced by the RBI?
The International Monetary Fund (IMF) has agreed to provide how much financial assistance to Ukraine as part of a larger $15.6 billion lending programme?
What is the theme of the ‘Indian Science Congress 2023’ which was inaugurated by Prime Minister in Maharashtra?
According to the data provided by the Reserve Bank of India, bank credit rose by 15 per cent year-on-year (YoY) in 2022-23 (FY23).What was the absolute ...
- Where was the second phase of Khelo India Winter Games 2025 hosted?