wood burning stoves 2.0*
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: 4343
    
    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: 3429
    
  12
Apart from the Object class of course


Joanne
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38007
    
  22
More about it here.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Do all the classes extend the Object class?
 
Similar Threads
Instance blocks.
inner class
Super class for all the classes in java
A question about anonymous class???
java.lang.Object is a class or Interface