Topic 26: Object class in Java
Object is a special class defined by Java.
Object is a superclass of all classes in Java. A Object class reference variable can refer to an object of any other class including arrays, since arrays are implemented as classes.
The following methods are available in every object:
Object clone( ) - Creates a new object that is the same as the object being cloned.
boolean equals(Object object) - Determines whether one object is equal to another.
void finalize( ) - Called before an unused object is recycled.
Class getClass( ) - Obtains the class of an object at run time.
int hashCode( ) - Returns the hash code associated with the invoking object.
void notify( ) - Resumes execution of a thread waiting on the invoking object.
void notifyAll( ) - Resumes execution of all threads waiting on the invoking object.
String toString( ) - Returns a string that describes the object.
void wait( ) - Waits on another thread of execution.
void wait(long milliseconds) - Waits on another thread of execution.
void wait(long milliseconds, int nanoseconds) - Waits on another thread of execution.
The methods getClass( ), notify( ), notifyAll( ), and wait( ) are declared as final. We may override the others.
Click for NEXT article.
Please feel free to correct me by commenting your suggestions and feedback.
No comments:
Post a Comment