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
- A 240-litre solution contains milk and water in the ratio 3:5 respectively. How much milk should be added to make the ratio of milk to water 7:10?
A container contains Alcohol and water in ratio of 5:3 and Capacity of Container is 80 lit. If half of the Container is replaced with 30 lit of water th...
A mixture contains milk and water in the ratio 5:6, respectively. If half of the mixture is replaced with 6 litres of water, then the resultant mixture ...
- A container holds 160 litres of a solution containing sugar and water in the ratio 3:5. How many litres of sugar should be added to make the new ratio 4:5?
In what ratio must rice at Rs 50 per kg be mixed with rice at Rs 65 per kg so that the mixture may be worth Rs 56 per kg?
- Cost price of wheat (per kg) of type 'A' and 'B' is Rs. 84 and Rs. 132 respectively. Both types are mixed and sold at Rs. 156 per kg at a profit of 30%. Fi...
A vessel has 20L of 25% acid solution. How much pure acid must be added to make it 40% acid?
In a mixture of milk & water, 45 litres water is mixed due to which ratio changes from 3 : 4 to 1 : 3. Find initial quantity of mixture. (in litres)
In a mixture of milk & water, 40 litres water is mixed due to which ratio changes from 3 : 4 to 1 : 4. Find initial quantity of mixture. (in litres)
- Mixtures A and B have milk and water in ratio 3:5 and 2:3 respectively. 40 ml from A and 45 ml from B are mixed. Find the percentage of water in the final ...