my dog learned polymorphism
The moose likes Java in General and the fly likes Why Objcet is the Base 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 Objcet is the Base class?" Watch "Why Objcet is the Base class?" New topic

Why Objcet is the Base class?

Santosh Maskar
Ranch Hand

Joined: Jul 02, 2003
Posts: 226
Why Sun took such a design decision for Objcet class as a Base class.

What is the speciail about the Objcet and why all classeses implemtes Object by default

Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
1. There are some methods common to all objects, like toString:

How could you have written such code without Object?

2. The Collection Framework (java.util.List, Set, Map, etc...)
rely heavily on Object to allow the defintion of general collections:

The current version of Java (1.5) compilcates this point with generics,
but the argument can still be made: Having a common base class is
very useful. C++, as you may know, lacks this, and most C++ Frameworks
begin by defining base classes that most their classes derive from,
directly or indirectly...

There is no emoticon for what I am feeling!
I agree. Here's the link:
subject: Why Objcet is the Base class?
It's not a secret anymore!