Question
In OOP, what term best describes the relationship where
one object is a part of another but cannot exist independently?Solution
Composition is a "has-a" relationship where one object contains another, and the contained object cannot exist independently of the parent. 1. Dependency: For instance, an engine is part of a car and cannot function independently outside of it. 2. Tight Coupling: The lifecycle of the child object depends entirely on the parent object. If the parent is destroyed, the child is destroyed too. 3. Reusability: Composition fosters code reuse by enabling modular design without strict inheritance hierarchies. Option A exemplifies composition through its strong containment relationship, central to creating complex, interdependent systems. Why Other Options Are Incorrect: • B) Aggregation: Denotes a weaker "has-a" relationship, where components can exist independently. • C) Inheritance: Refers to property sharing, not containment. • D) Polymorphism: Focuses on method behavior variability. • E) Association: A general relationship without specific containment rules.
147 490 707 831 895 922 930
...Find the wrong number in the given number series.
7, 8, 17, 42, 83, 172Find the wrong number in the given number series.
63, 66, 57, 75, 51, 81
Find the wrong number in the given number series.
45, 68, 39, 70, 27, 74
Find the wrong number in the given number series, If wrong term is 'p', then find the value of √(p - 17) .
1195, 1172, 1143, 1106, 1075, 10...
Find the wrong number in given number series.
6490, 6377, 6294, 6211, 6138
- Find the wrong number in the given number series.
25, 36, 29, 40, 33, 50 - Find the wrong number in the given number series.
25, 34, 18, 34, 9, 46 Find the Wrong number in the given number series.
29, 76, 123, 166, 209, 256Direction: Find the wrong number in given number series.
958, 954, 981, 948, 1299, 1218