It's not a secret anymore!*
The moose likes Beginning Java and the fly likes IS A and HAS  A   Relationship Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "IS A and HAS  A   Relationship" Watch "IS A and HAS  A   Relationship" New topic
Author

IS A and HAS A Relationship

kiranb reddy
Greenhorn

Joined: Sep 28, 2008
Posts: 20
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

Joined: Sep 02, 2008
Posts: 87
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


SCJP 5.0, SCJD in progress
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11172
    
  16

an apple IS A fruit.

an apple HAS A seed.

a Ford Mustang IS A car

a Ford Mustang HAS A windshield.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
John Eric
Greenhorn

Joined: Nov 16, 2010
Posts: 1
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

Joined: Jun 07, 2011
Posts: 115

Best artical on IS-A and HAS-A relationship
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: IS A and HAS A Relationship
 
Similar Threads
Trying to access the instance variable of Class Bar from Class Foo --------- why error ?
WA #1.....word association
Webservices and .NET
Containment
Composition Vs Inheritance