adspace
What is the difference between containment and delegation?
Answer Posted / Awadhesh Prasad Gaur
Containment is a relationship in which one object has a pointer or reference to another object, allowing the containing object to access and manipulate the contained object. Delegation, on the other hand, is a design pattern in which an object defers some of its responsibilities to another object, usually by forwarding method calls to that object. In containment, the contained object is part of the containing object's lifetime; in delegation, the delegate object is independent.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers