Skip to main content

#TC201 #Topic7 What are”has-a” and “is-a” relationships?

1 min read

In a very easy way to explain this:

Is - a relationship is an inheritance, for example a Dog is an animal, in Java this is done by the "extends" keyword.

Has - a relationship is a composition, for example a Dog has eyes, in Java this is done by having Dog an instance object of Eye.



Inheritance v Composition