What is composition?

DWQA QuestionsCategory: JavaWhat is composition?
1 Answers
Editor Staff answered 11 months ago

Holding the reference of a class within some other class is known as composition. When an object contains the other object, if the contained object cannot exist without the existence of
container object, then it is called composition. In other words, we can say that composition is the particular case of aggregation which represents a stronger relationship between two
objects. Example: A class contains students. A student cannot exist without a class. There exists composition between class and students.