Question
Which type of relationship between classes in OOP is
best represented when one class is a part of another class but can exist independently?Solution
Aggregation is a type of association that represents a "whole-part" relationship between two classes. The key characteristic is that the part (child object) can exist independently of the whole (parent object). For instance, in a Team class and Player class, a Player can exist without being associated with a Team . Aggregation is implemented by using references, where one class has an attribute referencing another class. This design principle promotes flexibility and modularity. Aggregation is often represented with a hollow diamond in UML diagrams. Why Other Options Are Wrong Option B : "Inheritance" Inheritance represents an "is-a" relationship, not a "whole-part" relationship. It is used to share functionality between classes, not to model part-whole dependencies. Option C : "Composition" Composition is similar to aggregation but with a crucial difference: the part cannot exist independently of the whole. For example, a Car and its Engine share a composition relationship because an engine has no meaning outside the car. Option D : "Association" Association is a broader concept that describes any relationship between classes. Aggregation is a specific type of association. Option E : "Polymorphism" Polymorphism is unrelated to class relationships and focuses on method behavior.
The LCM of two numbers is 960 while their product is 7680. Find the greatest common divisor of the two numbers.
The HCF of two numbers is 6 and their LCM is 84. If one of these numbers is 42, then the second number is:
The HCF of two numbers is 14. Which of the following can never be their LCM?
The product of two numbers is 1344 and their L.C.M is 168. What is the H.C.F of the two numbers?
- The sum and difference of L.C.M and H.C.F of two numbers is 216 and 184. If one of the numbers is 25, then find the other number.
The HCF and LCM of the two numbers are 225 and 360 respectively. When the first number is divided by 3, the quotient is 20. The other number is.
Find the LCM of the numbers 1.2, 0.8, 2.4, and 3.6.
Two numbers are in the ratio 2:8. The product of their H.C.F. and L.C.M. is 3600. The sum of the numbers is: