A question so simple , yet confusing to decifer , why is the superclass of all classes in java named as 'object' class ? It could be anything else , any particular reason/thoughts for the same would be helpful.
TIA, Vijay
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
4
posted
0
I always thought that in object-oriented programming all objects are objects so you call them Object . . .
Sanjaya Sugiarto
Ranch Hand
Joined: Mar 25, 2004
Posts: 229
posted
0
What would be a better name in OO-language that the superclass called Object? Interesting question, for exact answer you should ask James Gosling though.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
posted
0
I'm pretty sure if I invented an OO language with a single ancestor at the top, I'd call it BOB. The framework I use has BOB-Objects and that just makes me very happy. Yup, BOB.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
It ts very good question and must be ansarable.Every class extends Object class Because of 2 resion,one is for security resion & other for utilities purpose.If a class Extends Object class ,then after jvm,cosider this program is secure program(thats the only way that jvm know program compile by bug free compiler or bug compiler).Other is about the utilites,thats G.C,&other functionalites.
Java is an object oriented language, so everything we create in Java is-an object.
Inheritance represents an is-a relationship with all parents, or specifically, ancestor classes. Since all classes in Java inherit, at the top of the tree, from a class called object, then we can honestly say that EVERY class we create is-an Object.
I just love the elegance of Java. It's everywhere, even in the little things like the Object class.
How about BaseClass? After all it is a class, not an object.
Still, it really doesn't matter why they named it Object.
"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
posted
0
It is interesting that they didn't have to have a common ancestor to everything if they didn't want to. In a strongly typed language it's good to have a place like this to put useful behavior. Look at the methods on Object. Could they have implemented these some other way without a single ancestor?
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
What about extending from a common class called Problem.
Then we could say: everything we code in Java is-a Problem
What else? Nuisance? ThingForSomeoneElseToDO? Challenge?
Dana Bothner-By
Ranch Hand
Joined: Jul 28, 2006
Posts: 37
posted
0
Originally posted by Rusty Shackleford: How about BaseClass? After all it is a class, not an object.
Last time I checked, every class was a class, but its instances are objects, and classes tend to new named after their objects, not? Actually, if we are suggesting new names, I like "Om", the sound that created the universe. Why not say it now, "Ooommmm". Ah...