Morgan Stanley Interview Question
Software Engineer / DevelopersContainment may refer to the (excuse for an) OO concept of incorporating class functionality by keeping a private reference, implementing an interface that the referant implements and delegating calls to the referant. Those of you not having spent time in that pit of despair known as Visual Basic may be forgiven for not being familiar with this shoddy excuse for not implementing a real OO language with class derivation.
and Inheritance is extending parent property and here you dot have any choice. so Inheritance is tightly coupled.
My answer would be inheritance is more tightly coupled as it forces child to implement abstract methods, invoke non-default constructors if there are none and such.
- Mikler June 26, 2011While containment is much easier to support.