Most Common Java Developer Interview Questions series-12(Core Java,OOP)

In this article, I will be posting commonly asked Java backend developer Interview Questions and their answers, They are common across all interviews. Find my book here Guide To Clear JavaDeveloper Interview, which contains more than 250 such questions and there answers.

Ajay Rathod
5 min readMar 10, 2023

--

Difference between Aggregation vs composition?

Aggregation and composition are two fundamental concepts in object-oriented programming (OOP) that describe the relationships between classes and objects.

Aggregation refers to the relationship between two objects where one object “has-a” another object, but the second object can exist independently of the first object. In other words, the first object owns or contains the second object, but the second object can also exist on its own.

Composition, on the other hand, is a stronger form of aggregation where the second object cannot exist without the first object. In other words, the first object “owns” the second object, and the second object cannot exist outside the context of the first object.

--

--

Ajay Rathod
Ajay Rathod

Written by Ajay Rathod

Java Programmer | AWS Certified | Writer | Find My Books on Java Interview here - https://rathodajay10.gumroad.com | YouTube - https://www.youtube.com/@ajtheory

No responses yet