Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why java.lang.Object is implicitely always extended?

 
Anup Katariya
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We all know that the java.lang.Object is always implicitly extended. But why java makers decided to do that. I mean I dont think c++ or any other oo language implicitly extends some base object.

Could we have done creating objects without extending to java.lang.Object?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12086
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could we have done creating objects without extending to java.lang.Object?


You answered your own question - like you said, C++ does not have every class extend a base object.

Why is it this way in Java? you could easily ask "why isn't it this way in C++?" The designers of the languages felt that, when you weigh all the options, the balance fell one way or the other.
 
Campbell Ritchie
Sheriff
Posts: 48402
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually the OO languages I have used all have a single superclass; Java and C# use "Object" and Eiffel uses "Any" which itself inherits from "General."
 
Anup Katariya
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply. Just confirmed my understanding that it is a better thing to do.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic