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
Two cars start from a place with a speed of 45 km/hr at an interval of 10 minutes. What is the speed of a man coming from the opposite direction towards...
Without stopping the speed of the train is 125 kmph, with stopping the speed of the train is 75 kmph.Find the stop time of the train?
Two buses, βXβ and βYβ, started simultaneously from city βMβ and city βNβ towards each other. When they crossed each other after 6 hours...
A train 450 metres long is running at a speed of 54 km/hr. If it crosses a tunnel in 1 minute, then the length of the tunnel (in meters) is:
A train running with a speed of 54 km/hr can cross a pole in 15 seconds and a platform in 22 seconds. Find the length of the platform.
Two trains started from stations βAβ and βBβ at same time and started travelling towards each other at speeds of 80 km/hr and 70 km/hr, respecti...
Train βAβ travelling with a speed of 42 km/h can cross a pole in 6 seconds. If the length of train βBβ is 10% less than that of train βAβ an...
- A train can cross a bridge and a pole in 6.4 seconds and 4 seconds respectively. The length of the bridge is 60 metres. Find the time taken by train to cro...
A train takes 5 seconds more to cross a 180-metre-long platform than it takes to cross a pole. If a car running at the speed of 42 m/s takes 80 seconds ...
Train βAβ of length 150 metres crosses a platform of length 250 meters in 20seconds. If the ratio of the speed of train βAβ to that of train β...