I read that every class extends a object class by default. then it should cause multiple inheritence and must not be supported by Java.

Please help me about this....

read that every class extends a object class by default.

Yes.

then it should cause multiple inheritence and must not be supported by Java.

Think of it like this: when you explicitly extend a class, Object isn't involved except as a base of the class being extended. When you don't explicitly extend a class, Object is automagically extended. Thus it's always single inheritance, but the extending class ultimately has a base of Object at the very top.

Edited 4 Years Ago by deceptikon

deceptikon: I follow your point, and I agree, but I'm not sure about the choice of words. Object will always be involved, I think you meant to say: it's not Directly inherited.

if you don't explicitly extend a class, you directly inherit the Object class.
if, on the other hand, you do explicitly extend a class (except when that class is Object, bit redundant, yet possible) you don't. but you do inherit everything from the superclass.

now, it that superclass doesn't explicitly extend a class (except for Object, of course) that class will extend Object. if it does explicitly extend a class, you will go from parent class to parent class untill you reach the top of the hiƫrarchy, in the end, you'll end up with a class that Directly inherits Object, and passes all it's contents and behaviour on to the sub classes (and that's sub classes, and so forth, and so on).

there is no multiple inheritance involved, even though it may look that way, when the basis of Java is that every class extends Object, but look at it this way:

a son inherits genes from his father and mother, but through them also from his grandparents.

Object will always be involved, I think you meant to say: it's not Directly inherited.

I did say that:

when you explicitly extend a class, Object isn't involved except as a base of the class being extended

Though I'll readily admit that the wording isn't my best. ;)

Object isn't involved

that's why I added that part :)
as I said, I agreed with your post completely, but for those who don't know the principle very good, it might make it harder to understand.

Though I'll readily admit that the wording isn't my best. ;)

you should read my posts from time to time :D

This article has been dead for over six months. Start a new discussion instead.