| 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: 163
|
|
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: 3860
|
|
|
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: 32830
|
|
|
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: 10040
|
|
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.
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
Winston Gutkowski
Bartender
Joined: Mar 17, 2011
Posts: 4902
|
|
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?
|
 |
Jayesh A Lalwani
Bartender
Joined: Jan 17, 2008
Posts: 1321
|
|
|
Object class extends from itself :p
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32830
|
|
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.
|
 |
 |
|
|
subject: why Object class doesn't have any super class?
|
|
|