Relationship in java
type of relationship always makes to understand how to reuse the feature from one class to another class. in java programming we have three types of relationship they are:-
. IS-A relationship (Inheritance)
. HAS-A relationship (Aggregation)
. User -A relationship
IS-A relationship
In an IS-A relationship, one class is obtaining the feature of another
class by using inheritance concept with extend keyword.
NOTE:- in an IS-A relationship there exists
logical memory space
Note:- the default relationship in java is IS-A because for
each and every class in java there exists an implicit
predefined superclass in java. lang.object
HAS-A relationship
In HAS-A relationship an object of one class is created as a
data member in another class the relationship between these
two classes in HAS-A
In HAS-A relationship there existed physical memory space
and it is also known as part of or kind of relationship
User -A relationship
A method of one class is using an object of another class the
relationship between these two classes is known as user-A relationship.
What is Inheritance ?
The process of obtaining the data members and methods from
one class to another class is known as inheritance
Type of Inheritance
. single
. multi-level
. multiple
single
In single inheritance one parent and one child class
multi-level
In multi-level inheritance derived from derived class
multiple
In multiple inheritances multiple parent but single child
0 Comments