aspose file tools*
The moose likes Beginning Java and the fly likes Determining IS-A & HAS-A Relationship when using Abstract Classes / Interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Determining IS-A & HAS-A Relationship when using Abstract Classes / Interfaces" Watch "Determining IS-A & HAS-A Relationship when using Abstract Classes / Interfaces" New topic
Author

Determining IS-A & HAS-A Relationship when using Abstract Classes / Interfaces

Ehsan Rahman
Ranch Hand

Joined: Feb 16, 2009
Posts: 59

Hi All,

Dog 'Is-A' animal.
Dog 'Has-A' dog collar.

However, is there any determination of IS-A or HAS-A relationship when using Abstract Classes?



Q's:
- Does RoboDog 'Have-A' barkLoudness of 5?
- Does RoboDog 'Have-A' or 'IS-A' bark() ?
- What about Interface methods and static variables if RoboDog were to implement them? Would they be considered 'HAS-A' or 'IS-A'?

Links to articles would also be helpful please.

Thanks in advance,
Ehsan


SCJP 1.5, SCJD 1.6
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Does RoboDog 'Have-A' barkLoudness of 5?
- Does RoboDog 'Have-A' or 'IS-A' bark() ?

Ehsan, you are misinterpreting the IS A and HAS A relationship. They are not comparable with state and behaviour of Class.
Please have look at IS-A and HAS-A.



Here Dog extends Animal and Dog is an instance of Animal. This is IS-A relationship.



Here Dog has an instance of Collar class. This is HAS-A relationship.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Determining IS-A & HAS-A Relationship when using Abstract Classes / Interfaces