File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Do all the classes extend the Object class?

 
Nittin singla
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4549
8
Java Netbeans IDE Scala
  • 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 3742
16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apart from the Object class of course
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More about it here.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic