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.
- What approximate value will come in place of the question mark (?) in the following question? (Note: You are not expected to calculate the exact value.)
(289.89 + 59.98) X 2.25 = ? X 49.66
What approximate value will come in place of the question mark (?) in the following question? (Note: You are not expected to calculate the exact value.)...
24.66% of 8640.31 + (56.06 × 14.11) ÷ 8 = ?
Which of the following options is the closest approximate value which will come in place of question mark (?) in the following equation?
26.52 ×...
25, 28, 26, 29, 27, ?
81% of 1550 + 27² = ? + 1386 ÷ 22
49.99% of 539.99 + 263.98% of 49.99 = ?% of 1608.01
Find the difference of day had the highest number of books and that of lowest number of books sold?
What approximate value will come in place of the question mark (?) in the following question? (Note: You are not expected to calculate the exact value.)...