File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Why one Super Class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Why one Super Class?" Watch "Why one Super Class?" New topic

Why one Super Class?

Ramaswamy Srinivasan
Ranch Hand

Joined: Aug 31, 2004
Posts: 295
Hi Author Jacquie / My fellow ranchers,

We all very well know that all the classes extend "java.lang.Object".

I was just thinking, why was such a design made. What are the advantages, that would be the fruits of this particular behaviour.

Care to explain?

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Well in my view, everything is an object so some *qualities* that all should have (quality of object because all are object) are kept in Object class and all classes are implicitly sub class of Object.
Vasilis Karas

Joined: Mar 16, 2004
Posts: 24
let me complement your question and ask why not? Is there a limitation that you've encountered??
This question is one for the true computer scientist which I won't pretend to be.
My guess would lead me to what the proponents (I'm included) of Java hail as it's greatest benefits:

1)Built as an easy to use and pure OO language
2)Is platform independent
3)Built with multi-threading in mind--

Hopefully all see these as fairly accurate statements...

These attributes most likely required a common superclass so our beloved JVM (platform specific) can work appropriately: regaining memory on any system (gc) and control it's threads (wait(), notify(), notifyAll())...

A more creationist view may be that because all matter (Objects in this case) be created from one source

Ramaswamy Srinivasan
Ranch Hand

Joined: Aug 31, 2004
Posts: 295
Hi Vasilis,

Thanks for the post. I agree with you.

By the way, i did not face any limitations, with this implementation.

I have thought of all these common features in a single place holder, easy to implement,OO, etc...

But the perspective in which i had put my question here is to just know what was the design condition, beyond all these, and how it helps in the internals of the JVM, other that this gc, threads, etc...

Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

Here's an article that talks about the benefits of a singly-rooted hierarchy:

Junilu - [How to Ask Questions] [How to Answer Questions]
Ramaswamy Srinivasan
Ranch Hand

Joined: Aug 31, 2004
Posts: 295
Hi Junilu,

This is really a good information. Thanks a lot, for letting me know.

I agree. Here's the link:
subject: Why one Super Class?
jQuery in Action, 3rd edition