• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Devaka Cooray
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
Bartenders:

inheritance

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you please explain the word "Deadly Diamond of Death" ??
 
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java doesn't support multiple inheritance because of Deadly Diamond of Death
Lets take an example:
1)take notebook and a pencil and start making a diagram

2)Suppose we have one class A, with method printMe()

3) We have two subclass B and C,Both inherits A,both Override printMe()
A

B C
connect them by arrow.

4) we have one more sublclass D, Now if Java supports multiple inheritance then we can write

class D inherits B,C

which means following :
A

B C

D

connect them by arrow again.

now suppose we have following;



Now tell me which verion of printMe() will be called , one which is defined in B or which is defined in C.
If you know the answer to this question you have understood Deadly diamond..
by the way check your paper you have already got one diamond shape diagram..!!
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my arrow diagram is not displaying properly here..

Let me try one again:
 
raja ramesh
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ThanQ for early response ..
 
There's a city wid manhunt for this tiny ad:
The new gardening playing cards kickstarter is now live!
https://www.kickstarter.com/projects/paulwheaton/garden-cards
reply
    Bookmark Topic Watch Topic
  • New Topic