Question
What type of relationship is represented by Aggregation
in Object-Oriented Programming?Solution
Aggregation is a "has-a" relationship where one object is composed of other objects, but the lifecycle of the contained objects is independent of the containing object . For example, a Teacher class might be associated with a School class, but even if the School object is destroyed, the Teacher object can continue to exist. Aggregation emphasizes shared ownership and loosely coupled associations, making it useful for scenarios requiring flexibility in object dependencies. Why Other Options Are Incorrect :
- "Is-a" relationship : This refers to Inheritance , where a subclass derives from a parent class.
- "Has-a" relationship with exclusive ownership : This describes Composition , where the contained objects' lifecycle is tied to the container.
- Parent-child relationship : This typically relates to Inheritance or tree structures , not Aggregation.
- Object-to-object message communication : This aligns with Message Passing , which focuses on interaction between objects rather than relationships
What is the total amount currently held in District Mineral Foundations (DMFs) across Aspirational Districts?
What method is HDFC Bank using to sell its 100% stake in HDFC Education?
What is the conservation status of the Mainland Serow according to the IUCN Red List?
The State of the World’s Forests (SOFO) 2022 report was released by which organisation?
Where are the headquarters of Softbank Group?
How many Farmers' Producer Companies (FPCs) were established in Nagaland to promote organic farming?
Which of following portal has been developed to digitally monitor and track the restoration and repatriation of children according to the protocol?
What was the primary driver for the Maldives' adoption of India’s Unified Payments Interface (UPI) system?
Which Indian para-athlete won her second consecutive Paralympic gold in the women’s 10m air rifle (SH1) event at the Paris Paralympics 2024?
What is the focus of the PM Janjati Adivasi Nyay Maha Abhiyaan (PM-JANMAN)?