• Post Reply Bookmark Topic Watch Topic
  • New Topic

object class  RSS feed

 
A Babu
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friends,
1. why OBJECT class is the only one super class for all
the classes in java.

2.Why notify() and notifyall() methods put in OBJECT class instead of putting Thread class

cheers,
babu.
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because my dear frnd Object is the Basic entity of every Java Class. I mean to say that as we are following Object Oriented Technology so in that Technology we need to consider every thing as an object. even we also load a object of Class loader to load the class and execute the class.
 
venkata redddy kesari
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Class Object is the root of the class hierarchy. Every class has Object as a superclass. All objects, including arrays, implement the methods of this class.
 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my dear frnd... not only wait() notify () are added to Object class...
but there are are some more methdos which are essential to each and every class...
cinux
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wait and notify are used to communicate between two or more threads. We wait to obtain a lock on an object and notify others when we make a lock available. The object we're all playing with is at the center of all this communication so the methods go very naturally there. We can wait or notify on any object of any type, so the methods wind up on the root Object class.

It would have been possible to define all these methods on Thread and make them take an object argument: someThread.wait(someObject) instead of someObject.wait() but the designers chose not to do that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!