File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Do all the classes extend the Object class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Do all the classes extend the Object class?" Watch "Do all the classes extend the Object class?" New topic
Author

Do all the classes extend the Object class?

Nittin singla
Greenhorn

Joined: Jul 02, 2011
Posts: 24
I want to know if all the classes extend the Object class.
If yes, then how does this code compile. "class A extends Object{}" as the same class cant be extended twice.
If no then how am i able to override the hashcode ,equals methods that are defined in Object class...

Please clear my doubt.
TIA
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4370
    
    8

Yes, they do (ultimately - they may extend a class that extends a class that extends Object, etc). So if you don't have an extends declaration there's an explicit "extends Object". But you're allowed to declare it explicitly if you want - there's no point disallowing it as there's no conflict.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3487
    
  13
Apart from the Object class of course


Joanne
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38472
    
  23
More about it here.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Do all the classes extend the Object class?