Why Objcet is the Base class?

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

Thanks, Santosh

Jeff Albertson

Ranch Hand

Posts: 1780

posted 12 years ago

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...