How to explain multiple inheritance in Java -


this question has answer here:

actually question asking 1 of interviewer

que: how can java not supporting multiple inheritance? if object class parent of classes in java.

i have no answer of question.

that means no clear idea java concepts :-(

ex: if a extends b

and here extending object class. right? how works?

please share answers..

multiple inheritance multiple-direct-inheritance.

a single class class can't have 2 immediate parent classes. can have grandparent class, though.

a extends b , b extends c, not same a extends both b , c.

the reason disallowed simplicity when have case like:

a extends both b , c  b extends d  c extends d 

if had such case, , had code:

a = new a(); a.someabstractorvirtualmethodond(); 

... talking b implementation of someabstractorvirtualmethodond(), or c implementation of same method? should called? (hint: there isn't great answer)

so, java bans it.

note, can multiple inheritance if implement multiple interfaces. since there 1 concrete implementation, there no confusion gets called.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -