Object class

Object Class:
There is one special class, Object, defined by java. All other classes are the subclasses of object. That is Object is super class of all other classes.
Object defines the following methods: ---------

  • Object clone ()
  • Void finalize()
  • Class getClass()
  • int hashCode()
  • String toString()
  • Void notify()
  • Void notifyAll()
  • boolean equals(Object object)
  • void wait()

  • Create a new object that is the same as the object being cloned
  • Called before an unused object is recycled.
  • Obtains the class of an object at run time.
  • Return the hash code associated with the invoking object.
  • Return a string that describes the object.
  • Resumes execution of a thread waiting on the invoking object.
  • Resumes execution of all threads waiting on the invoking object.
  • Determines whether one object is equal to another
  • Waits on another thread of execution.

The methods getClass(),notify(),notifyAll(),and wait() are declared as final.
The equals () method compare the contents of two objects. it returns true if the objects are equivalent ,and false otherwise .the toString() method returns  a string that contains a description of the object on which it is called. Also, this method is automatically called when an object is output using println()


Post a Comment