Aggregation implies a relationship where the child can exist independently of the parent . For example, Bank and Employee, delete the Bank and the Employee still exist. whereas Composition implies a relationship where the child cannot exist independent of the parent.
Read moreWhy do we need composition in Java?
Benefits of using Composition: Composition allows us to reuse the code . In Java, we can use multiple Inheritance by using the composition concept. The Composition provides better test-ability of a class. Composition allows us to easily replace the composed class implementation with a better and improved version.
Read moreIS-A relationship in oops?
In OOP, IS-A relationship is completely inheritance . This means, that the child class is a type of parent class. For example, an apple is a fruit. So you will extend fruit to get apple.
Read moreWhat are the 3 types of inheritance in Java?
On the basis of class, there can be three types of inheritance in java: single, multilevel and hierarchical .
Read moreWhat is inheritance in program?
What is Inheritance in Object Oriented Programming? Inheritance is the procedure in which one class inherits the attributes and methods of another class . The class whose properties and methods are inherited is known as the Parent class.
Read moreWhat is inheritance give example in Java?
In Java, inheritance is an is-a relationship. That is, we use inheritance only if there exists an is-a relationship between two classes. For example, Car is a Vehicle .
Read moreWhat are the types of inheritance in Java?
On the basis of class, there can be three types of inheritance in java: single, multilevel and hierarchical . In java programming, multiple and hybrid inheritance is supported through interface only. We will learn about interfaces later.
Read more