(IS A ) and (HAS A) relationship in Java
Relationship between the classes.
----------------------------------------
( IS A ) relationship -- Parent class
doesn’t depend on child.
Class Animal {
}
Class Dog {}
Class Dog extends Animal {
// tightly coupled all properties
inherited of Animal
}
( Has A ) relationship ---
Association :--
Class Bank
{ }
Class Employee {}
Class
OpenBank {
Bank axis =new Bank () ; //
Independent //loosely coupled
Employee manager =new Employee( ); //Independent
}
Composition :--
Class Car {
}
Class Engine {}
Class MusicPlayer{}
Class
CarMove {
Engine a=new
Engine() ; // Most needed /dependent
}
Engine is most essential component
to car move. So its composition. Engine can be change.
Aggregation :--
Class CarMove {
MusicPlayer
mp=new MusicPlayer(); // Not essential
Engine e =new Engine(); //
}
Music
Player not essential component but
overall it part of car . Aggregate
future of car.
Diagram which shows the Has
A relations .
Composition and Aggregation are Associations.
(IS A ) and (HAS A) relationship in Java
Reviewed by Mukesh Jha
on
11:26 PM
Rating:

No comments:
Add your comment