aspose file tools*
The moose likes Beginning Java and the fly likes why object class only the top level class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "why object class only the top level class" Watch "why object class only the top level class" New topic
Author

why object class only the top level class

T sandya
Ranch Hand

Joined: Aug 03, 2006
Posts: 64
Hi,
why object class only the top level class for all classes?
what is the special in that?
why object class only they make as root class instead of making some other classes as root classes?

please discuss your opinions.

Regards,
Sandya.
dhwani mathur
Ranch Hand

Joined: May 08, 2007
Posts: 621
Well i think the below shown link can help you to understand why object class is the top level class,although there may be many reasons but some can be explained as follows...


http://www.particle.kth.se/~lindsey/JavaCourse/Book/Part1/Java/Chapter04/Object.html


i hope it helps you.
dhwani mathur
Ranch Hand

Joined: May 08, 2007
Posts: 621
i think this below shown link will make you more clear..


http://journals.ecs.soton.ac.uk/java/tutorial/java/javaOO/objectclass.html
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
The Java designers wanted to make certain functionality available to absolutely all objects, so they created an Object class and made everything inherit it.

Not all languages are like this. C++, for instance, has no common superclass. Hence there are no data or methods shared by all C++ classes.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2718
    
    6

Hi,
The Object class is the only top level class in Java because as already posted above, there must be some common functionality inherent in all objects, one such commonly used functionality is String representation of the object.
Also one another important aspect of using a single top level class is to
facilitate the use of Single Rooted Hierarchy.
Besides its several purposes, one important feature obtained is that you can use the generic Object in your code and decide the actual (required) type of object dynamically during runtime.

You can also find out more reasons by further reading.
Hope it helps


SCJP, SCWCD.
|Asking Good Questions|
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
There must be some common functionality inherent in all objects ,,,


Don't forget that was a decision of the language designer, not a cosmic truth. You can find other languages that don't have a common ancestor class. That doesn't matter much in Java but one day you'll get bored with Java and try the Next Big Language that might not agree.


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
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Also see The singly rooted hierarchy topic from Eckel's Thinking in Java.


"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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why object class only the top level class