Object class in Java: special class, methods defined by object class

Object is a specially defined super class in Java and all other classes are sub classes of the object class. Methods defined by object class:

void finalize( ): It is called before recycling an unused object.

void notify( ) and void notifyAll( ): Both are used to resumes execution of a thread.

Object clone( ):  It is used to create a new object by cloning.

boolean equals(Object object): It is used to find if one object equals another.

Class getClass( ): It is used to get class of an object at run time.

int hashCode( ): It is used to return the hash code associated with the object.

String toString( ): It is used to return a string.

void wait( ): It is used to for waiting on another thread of execution.

Leave a Reply