Aggregation: It represents a Has-A relation. Its a one way relationship which means that a departments can have multiple students but a student cant belong to multiple departments. Also in aggregation both the entities can exists independently which means that they are not dependent on each other, ending one entity
Association: Its the relationship between two separate classes by their objects. It can be one to one, one to many, many to one and many to many. Composition and Aggregation are two forms of Association. Aggregation: It represents a Has-A relation. Its a one way relationship which means that a
Polymorphism mean the condition of occurring in several different forms Polymorphism in Java has two types: Compile time polymorphism (static binding) and Runtime polymorphism (dynamic binding). Method overloading is an example of static polymorphism, while method overriding is an example of dynamic polymorphism. Polymorphism represents a IS-A relationship Consider a
Multiple inheritance is not supported in case of class because of ambiguity. But it is supported in case of interface because there is no ambiguity as implementation is provided by the implementation class. When a class implements multiple interfaces, or an interface extends multiple interfaces i.e. known as multiple inheritance.
Interface in java is a model/prototype of a class. It has static constants and methods (without implementation). There can be only abstract methods in the java interface not method body. It is used to achieve abstraction and multiple inheritance in Java. It cannot be instantiated. Three reasons to use interface. They
Abstraction is to hide the unnecessary details from the user and to show only relevant things/data to the user. Abstract class: Abstract class in Java contains the abstract keyword. If a class is declared abstract, it cannot be instantiated, means that you cannot create an object of an abstract class. Also, an
Encapsulation is a technique in which you can bind your data and code together as a single unit. It’s a good approach to hide your data to make it safe from any modification. The best way to understand encapsulation is to look at the example of a medical capsule, where the
Inheritance is such a concept in which one object interact with the other object, where the properties of one class can be inherited by another class. It help developer or programmer to reuse code and create a new bond between classes. Two things involved in this process; Parent class (Base