What is composition in Java with example?

A composition in Java between two objects associated with each other exists when there is a strong relationship between one class and another . Other classes cannot exist without the owner or parent class. For example, A ‘Human’ class is a composition of Heart and lungs. When the human object dies, nobody parts exist.

Read more

What is uses a relationship in Java?

Dependence (Uses-A) Relationship in Java When we create an object of a class inside a method of another class , this relationship is called dependence relationship in Java, or simply Uses-A relationship. In other words, when a method of a class uses an object of another class, it is called dependency in java.

Read more