Frequently Asked Interview Questions

Composition

Composition ("is part of"):

Composition is also known as a 'is a part of' relationship because the member object is a part of the containing class and the member object cannot survive or exist outside the enclosing or containing class or doesn’t have a meaning after the lifetime of the enclosing object.

Example: If we were going to model a car, it would make sense to say that an engine is part-of a car. Within composition, the lifetime of the part (Engine) is managed by the whole (Car), in other words, when Car is destroyed, Engine is destroyed along with it.

Most Visited Pages

Home | Site Index | Contact Us