-2

Inheritance (IS-A) vs. Composition (HAS-A) Relationship

please someone explaine what is Inheritance (IS-A & HAS)relationship in java

faisal khan
  • 47
  • 1
  • 1
  • 3
  • If you type composition vs. inheritance into google you'll find a lot of existing articles written about this. The chance that whoever answers this question will write a better explanation than all the ones already out there is very low – Ben Aaronson Jun 11 '14 at 16:54

1 Answers1

5

Inheritance: Dog 'is an' Animal. In Java this is done by the extends keyword.


Composition: Dog 'has' Eyes. In Java this is done by having Dog an instance object of Eye.

Dov Benyomin Sohacheski
  • 7,133
  • 7
  • 38
  • 64
user2810895
  • 1,284
  • 3
  • 19
  • 33