• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

why Object Class was chosen Parent to all java classes?

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why Object Class was chosen Parent to all java classes?
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it sounded like a good idea at the time
 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java borrowed alot of ideas from Smalltalk. In Smalltalk everything is an object
 
Ranch Hand
Posts: 502
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
because every object in java is an umm.. object and all the properties and methods common to all objects are in the Object class
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Nigel Browne
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic