Aggregation helps in reusing the code . Object B can have utility methods and which can be utilized by multiple objects. Whichever class has object B then it can utilize its methods.
Read moreWhy do we use aggregation in Java?
Aggregation helps in reusing the code . Object B can have utility methods and which can be utilized by multiple objects. Whichever class has object B then it can utilize its methods.
Read moreWhat is composition how it is used?
The main reason to use composition is that it allows you to reuse code without modeling an is-a association as you do by using inheritance . That allows stronger encapsulation and makes your code easier to maintain as Joshua Bloch explains in the 3rd edition of his book Effective Java.16 Oca 2018
Read moreWhat is composition how it is used?
The main reason to use composition is that it allows you to reuse code without modeling an is-a association as you do by using inheritance . That allows stronger encapsulation and makes your code easier to maintain as Joshua Bloch explains in the 3rd edition of his book Effective Java.16 Oca 2018
Read moreWhat is the difference between composition and inheritance?
Inheritance and composition are two programming techniques developers use to establish relationships between classes and objects. Whereas inheritance derives one class from another, composition defines a class as the sum of its parts .
Read moreWhat is the difference between composition and inheritance?
Inheritance and composition are two programming techniques developers use to establish relationships between classes and objects. Whereas inheritance derives one class from another, composition defines a class as the sum of its parts .
Read moreIs a relationship example?
For example, if a class Bulb inherits another class Device, then we can say that Bulb is having is-a relationship with Device , which implies Bulb is a device.
Read more