Composition "Have a " Relationship OR "Must have" relationship between two or more classes. Container class contains component's class object For example a Car is composed of engine and body. Where Car is a container class and both Engine and Body are components class. Life Time Issue in Composition Life time of component objects depends on container class If Container object destroyed, component objects will be also destroyed Car Example There is a composition relationship between car's body and engine. Car must have Engine and body If Car destroyed, both Engine and Body will be destroyed class Engine { Engine () { System.out.println ( "Engine created" ) ; } void start () { System.out.println ( "Engine Start" ) ; } } class Body...
Java tutorials and example codes to deliver the basic concept. Blog contains lots of code examples in java.