File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why Objcet is the Base class?

 
Santosh Maskar
Ranch Hand
Posts: 226
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

Thanks,
Santosh
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic