| Author |
why Object Class was chosen Parent to all java classes?
|
kesava chaitanya
Ranch Hand
Joined: Aug 15, 2001
Posts: 140
|
|
|
why Object Class was chosen Parent to all java classes?
|
 |
Jeroen Wenting
Ranch Hand
Joined: Oct 12, 2000
Posts: 5093
|
|
it sounded like a good idea at the time
|
42
|
 |
Nigel Browne
Ranch Hand
Joined: May 15, 2001
Posts: 673
|
|
|
Java borrowed alot of ideas from Smalltalk. In Smalltalk everything is an object
|
 |
Jayesh Lalwani
Ranch Hand
Joined: Nov 05, 2004
Posts: 502
|
|
|
because every object in java is an umm.. object and all the properties and methods common to all objects are in the Object class
|
 |
Mahesh Bhatt
Ranch Hand
Joined: Sep 15, 2004
Posts: 88
|
|
Hi All, I think the reason was, They designed a class named 'Object' which had a few really good methods and then they used the benefits of inheritance. So now whenever we define a class, we have a few methods from the Object class as well. Can anybody out there, give a really good explaination about this. I think there is much much more than, what appears here.
|
Impossible is I M Possible
|
 |
Nigel Browne
Ranch Hand
Joined: May 15, 2001
Posts: 673
|
|
In Java it is important to understand what the definition of an object is.
An object is a class instance or an array
This definition is slightly different from that of SmallTalk, C++ and a host of other OO languages. The reason this is significant is that Interfaces in Java are not considered Objects and therefore, we are allowed to implement more than one Interface while only extending only one direct Superclass. Other languages allow for inheritence from more than one superclass (multiple polymorphism), in java this can only be achieved by abstract classes using other abstract classes.
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
Consider how nicely the single base class called Object works out for us. You can take any kind of object at all and store it in an Object variable or pass it to an Object parameter: Lists and Maps and Sets and such can store any object because they are written this way.
|
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
|
 |
 |
|
|
subject: why Object Class was chosen Parent to all java classes?
|
|
|