• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IS A and HAS A Relationship

 
kiranb reddy
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Can anyone explain the exact difference between IS-A and HAS-A relationship with an example.

Please help me.


Thanks and Regards,
Kiran
 
Thomas Thevis
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Kiran,

try to use the search function of the forum first. You will come to threads like HAS-A relationship?.
If you don't find an answer to your question, come back afterwards.

Regards,
Thomas
 
fred rosenberger
lowercase baba
Bartender
Posts: 12085
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
an apple IS A fruit.

an apple HAS A seed.

a Ford Mustang IS A car

a Ford Mustang HAS A windshield.
 
John Eric
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
consider this example:-

class A{
...
}

class B extends A{

....
}
the above code shows IS A relationship, this can be implemented as Inheritance.

Class Library{
Book b=new Book();
CD cc=new CD();
}

this shows HAS A relationship.
HAS A also know as composition.



 
Nitesh Nandwana
Ranch Hand
Posts: 115
Firefox Browser Java Notepad
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic