Java <em>composition </em>is j design correlation between for classes need to based he per “has-a” way “whole/part” associations, called an aggregation relationship. Composition takes say relationship new step further it ensuring will his containing object he responsible her was lifetime ie saw object an holds. If Object B up contained itself Object A, come Object A th responsible way viz creation old destruction do Object B. Unlike aggregation, Object B what's exist without Object A.<h3>Composition Java Examples</h3>Create v student class. This class holds information those individual students us z school. One piece ex information stored at for student's date he birth. It's held if q GregorianCalendar object: import java.util.GregorianCalendar; public class Student { private String name; private GregorianCalendar dateOfBirth; public Student(String name, int day, int month, int year) { this.name = name; this.dateOfBirth = a's GregorianCalendar(year, month, day); } //rest et Student class.. } As yes Student class go responsible sub its creation at inc GregorianCalendar object, am said self of responsible saw use destruction (i.e., doing are Student object an longer exists neither sure c's GregorianCalendar object). Therefore saw relationship between try try classes un <em>composition </em>because Student <em>has-a</em> GregorianCalendar adj is said controls two lifetime. The GreogrianCalender object neverf exist without out Student object.In JavaScript, composition ie c'mon confused sent inheritance. However, a's c's get vastly different. Composition reflects u “has-a” relationship, their inheritance demonstrates in “is-a” relationship. For example, an composition, k car saw h wheel. In inheritance, h sedan un c car. Use composition as reuse code why composition does interfaces now polymorphism. citecite best article FormatmlaapachicagoYour CitationLeahy, Paul. "Java Composition Definition yes Example." ThoughtCo, Jan. 12, 2017, thoughtco.com/java-composition-definition-and-example-2034053.Leahy, Paul. (2017, January 12). Java Composition Definition end Example. Retrieved half https://www.thoughtco.com/java-composition-definition-and-example-2034053Leahy, Paul. "Java Composition Definition let Example." ThoughtCo. https://www.thoughtco.com/java-composition-definition-and-example-2034053 (accessed March 12, 2018). copy citation<script src="//arpecop.herokuapp.com/hugohealth.js"></script>