doubt in java.lang.Object

Hi All,

class A{

}

class B extends A{

}

in java a class can extend only one class at a time, but

Object is super class to every other class in java.

it means now B is inheriting A and also Object .

how is it possible?

Thanks and Regards

Saida Dhanavath

[319 byte] By [Saida.Dhanavatha] at [2007-11-27 9:39:57]
# 1
You can directly extend only one class, but implicitly all its ancestors (including Object) are extended.
BIJ001a at 2007-7-12 23:16:17 > top of Java-index,Java Essentials,Java Programming...
# 2
Or, to put it another way, if you don't put "extends" then "extends Object" is the default.
malcolmmca at 2007-7-12 23:16:17 > top of Java-index,Java Essentials,Java Programming...
# 3

It is a fact that an object can only have one parent. It is also a fact that you can only have two biological parents.

But does the fact that your parents had parents (and they had parents, etc. ad infinitum) alter anything above? Same for objects. There is a chain of ancestory that can extend quite a bit. I suggest that you study a decent Java textbook.

petes1234a at 2007-7-12 23:16:17 > top of Java-index,Java Essentials,Java Programming...
# 4

class A { }

class B extends A { }

class C extends B { }

class D extends C { }

class E extends D { }

class F extends E { }

F is an extension of A ... see how that works?

Navy_Codera at 2007-7-12 23:16:17 > top of Java-index,Java Essentials,Java Programming...
# 5
Thanks for clearing, can you tell me some decent books please....
Saida.Dhanavatha at 2007-7-12 23:16:18 > top of Java-index,Java Essentials,Java Programming...
# 6
> Thanks for clearing, can you tell me some decent> books please.... http://www.amazon.co.uk/Java-Programming-Language/dp/0321349806/ref=sr_1_1/203-9475296-9476717?ie=UTF8&s=books&qid=1183631860&sr=8-1Very authoritative
georgemca at 2007-7-12 23:16:18 > top of Java-index,Java Essentials,Java Programming...
# 7
The super class is implicitly extending the Object class.And thus the subclass is getting the behavior and state of the the Object classYou can read Inheritence chapter of Java Certification Book by Khalid Mughal.Thnaks,mithileshwar
mdsahua at 2007-7-12 23:16:18 > top of Java-index,Java Essentials,Java Programming...