umlrelationshipdiagrams

What is the relationship between a Queue class and Node class is it inheritance, Association or Aggregation?


if im using the node class in the Queue like

Node tmpNode = new Node();

What would that relationship be called?


Solution

  • Here you create the Node object inside Queue. This means the Node object's existence completely depends upon Queue object's existence. If Queue object is destroyed, then there is no way for Node object to survive.

    In Aggregation, the life of an object may not depend on its container. That means, the referenced object may survive even the container is destroyed.

    Hope this link gives you better understanding on Aggregation and Composition with proper Java code samples.