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
Shivank purchased a total of 630 kg of wheat, rice, and pulses in the ratio 3:2:4, respectively. After selling 70% of the wheat, 40% of the rice, and 40...
If three numbers are in the ratio of 1:3:5 and their sum is 9000. Find the largest of the three numbers.
- In a company of 720 employees, the ratio of men to women is 5:4. Among men, the ratio of married to unmarried men is 3:2. Among women, the ratio of married...
- Rs. 42000 is divided among 'Aman', 'Bhanu' and 'Chirag' in such a way such that amount received by 'Aman' is (7/10) of amount received by 'Bhanu' and (7/4)...
The ratio of number of girls to number of boys is 3 : 2 in a class of 60 students. The average marks scored by the boys in Physics is 72 and the average...
The ratio of tea cups to coffee cups in a canteen is 6:5. If 18 tea cups are broken and 12 new coffee cups are added, the count of both becomes equal. F...
The sum of two numbers is 25 and their difference is 15. The ratio of the numbers is:
4%of the selling price of an article is equal to 5% of its cost price. Again 20% of the selling price is Rs.120 more than 22%ofits cost price. The ratio...
- โAโ, โBโ and โCโ divide a certain sum of money among themselves. The average of the amount with them is Rs. 4520. Share of โAโ is 10(2/3)% ...
The sum of three numbers A, B and C is โน11,800. The ratio of Aโs share to Bโs share isย 3 : 4 , and the ratio of Bโs share to Cโs share isย ...