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.
Statements:
8% rays are satellites.
All satellites are planets.
A few stars are satellites.
Conclusions:
I. All stars...
Statements-:
Some teachers are doctor
Some doctors are police
Some police are army.
Conclusions-:
I. Some Teach...
Statements:
A few parrots are hens.
No parrot is bird.
All bird are sparrows.
Conclusions:
I: Some hens are not b...
Statements: All mouse are keyboard.
Some keyboard are speaker.
No monitor is speak...
- Statements:
Only a few hemispheres is atmosphere.
None of the atmosphere is atom.
No atom is a base.
Conclusions:
I... Statements:
Only Tool is Screw
Some Tool is Nut
All Nut are Bolt
Conclusions:
I. All Nut can be Tool
II. All Screw can Bolt
Statements:
Some Gold are Silver
All Silver are Bronze
Some Bronze are Copper
Conclusions:
I. Some Bronze are ...
Statements: No book is a pen.
All copies are books.
All books are telephones.
No radio is a telephone.
Conclusions: I. ...
Conclusions:
I. All Drivers can be Conductors.
II. Some Tractors are Cars.
III. Few Cars are not Tram.
Statements:
Two statements are given, followed by two conclusions numbered I and II. Assuming the statements to be true, even if they seem to be at a variance with...