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.
The experience of our brand partners varies greatly.
P. Sometimes suppliers are reluctant to do something differently.
Q. Because the...
Connect the two rearranged sentences using the correct connectors from the options.
I. Sri Lanka may need (A) a bridge loan whether (B) an extern...
In the question below, three sentences are given followed by four connectors. From the options below, choose the one that provides the correct combinat...
Select the phrase/connector from the given three options which can be used to form a single sentence from the two sentences given below, implying the s...
He's still a bit of a square peg in a round hole here, which I'm sure is at least somewhat intentional, but it proves to be somewhat detrimental this ti...
- In each question, there are two statements which can be combined into a single statement in a number of different ways without changing their meaning. Belo...
Identify the exclamatory sentence
1. Nuclear medicine imaging runs almost entirely on Molybdenum-99, a radioisotope produced by nuclear fission of enriched uranium that decays so rapidly...
In the following question, two statements and five connectors are given. Only one of the connectors from those given can be used to combine the given t...
Select the phrase/connector from the given three options which can be used to form a single sentence from the two sentences given below, implying the s...