This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes why Object class doesn't have any super class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "why Object class doesn Watch "why Object class doesn New topic
Author

why Object class doesn't have any super class?

Soumya Ranjan Padhi
Greenhorn

Joined: Jun 27, 2012
Posts: 10
If in java every class must extend one class, then the java.lang.Object is also a java class and hence the question is does it have any Super class ? If not why?
Rameshwar Soni
Ranch Hand

Joined: Feb 03, 2011
Posts: 247
I don't know the actual answer but i think it has to stop at some place, say if Object class had a super class you would ask why this super class of Object class doesn't have another super class and the cycle would go on and on.

Secondly there are certain things which we have accept the way they are made by the people who made Java and lastly being an OOP language i think Object class being the top class is well justified.

And welcome to Ranch!!!
Rajdeep Biswas
Ranch Hand

Joined: Mar 26, 2012
Posts: 186

If in java every class must extend one class

Not a good sense, but true as Object class is parent for explicitly non-extending classes.

Object class was provided for basing functionalities that is required by every class that we create for running in JVM, identification, etc [Look at the methods]. So other classes by default extend it.
Now, for that matter, the basic functionalities are already in Object class, so why would it require to extend any other class!

The Object class is at the topmost position in the hierarchy, until the JVM is revisioned for toppling that decision.
You create "something" out of nothing. Things A, B and C were introduced following your something, so they extend it. Why should your "something" thats born out of nothing should extend "something else".


The biggest gamble will be to ask a question whose answer you know in that it will challenge your theory | www.TechAspire.blogspot.in
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4343
    
    8

You've got to have something at the top of the inheritance tree, otherwise you'd have an infinite number of classes.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37953
    
  22
The java.lang.Object class was designed to be the very top of the inheritance tree for everything. Look what it says in the link (second word in this post).
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11153
    
  16

Soumya Ranjan Padhi wrote:If in java every class must extend one class

But that is clearly not true, since the Object class does not, so the rest of your question is meaningless.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7526
    
  18

fred rosenberger wrote:But that is clearly not true, since the Object class does not, so the rest of your question is meaningless.

Ah, syllogism; don't you love it?

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2272
    
  28

Object class extends from itself :p
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37953
    
  22
Jayesh A Lalwani wrote:Object class extends from itself :p
have a look at this, too.

Unless you know something I don’t, like today being 1st April rather than 31st October, please stop that sort of joke. The newbies will believe you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why Object class doesn't have any super class?
 
Similar Threads
need help urgently
need help urgently
What is difference between Top Level Class and Super Class?
constructor
need help urgently