Object Class


java.lang
Class Object

java.lang.Object

  *public class Object:

  • Class Object is the root of the class hierarchy.

  • Every class has Object as a superclass.

Version:

JDK1.0

*Methods of Oject Class:

           Object Class consists of following 11 methods

1. public boolean equals(Object obj)

    Indicates whether some other object is “equal to” this one.

  2. public int hashCode()

    Returns a hash code value for the object

  3. protected Object clone()        Throws CloneNotSupportedException

Creates and returns a copy of this object.

  4. public String toString()

   Returns a string representation of the object

   5. public final Class getClass()

     Returns the runtime class of this Object.

   6. protected void finalize()throws  Throwable

             Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

7. public final void wait()

                throws InterruptedException

Causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object

  8. public final void wait(long timeout)

                throws InterruptedException

Causes the current thread to wait until either another thread invokes the notify() method or the notifyAll() method for this object, or a specified amount of time has elapsed.

  9. public final void wait(long timeout)

                throws InterruptedException

Causes the current thread to wait until either another thread invokes the notify() method or the notifyAll() method for this object, or a specified amount of time has elapsed.

 10.public final void notify()

    Wakes up a single thread that is waiting on this object’s monitor.

  11. public final void notifyAll()

    Wakes up all threads that are waiting on this object’s monitor.