aspose 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
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: 4384
    
    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: 3524
    
  15
Apart from the Object class of course


Joanne
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38729
    
  23
More about it here.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Do all the classes extend the Object class?