aspose file tools*
The moose likes Java in General and the fly likes please comment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "please comment" Watch "please comment" New topic
Author

please comment

Vinay Gangoli
Greenhorn

Joined: Jun 13, 2003
Posts: 22
hi all....although this is a widely discussed topic..i was hoping i cud get some clear insights here. I was wondering how a class can extend a class and the class Object at the same time.
please help...thanks and regards


SCJP 1.4<br />" Somedays ur the dog...other days ur the water hydrant "
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Every class extends either Object, or some other class. Object is thus ultimately the ancestor class of all other classes.
Does that answer your question?


[Jess in Action][AskingGoodQuestions]
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11398
    
  16

to be a little clearer, if class A extends class B, you can say "A is a B".
if B then extends C, "B is a C". by the transitive property, you can say "A is a C". and so on and so on...
if the class definition doesn't SAY it extends anything, it extends Object by default.
so, A extends B extends C extends Object.
[ March 01, 2004: Message edited by: fred rosenberger ]

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Vinay Gangoli
Greenhorn

Joined: Jun 13, 2003
Posts: 22
thanks for the quick replies....that cleared some air...What happens if A extends B and B extends A....is this a complier error ?. and if not how does class Object fit in ?
thanks
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Yes, circular inheritance is an error, either at compile time or at runtime.
Vinay Gangoli
Greenhorn

Joined: Jun 13, 2003
Posts: 22
thanks ...I got it now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: please comment