Core java tutorial for beginners
A tutorial blog which explains different core concepts related to Java along with programming examples

October 30, 2015 Categories: Inheritance. No Comments on Object Class

In this article we will look at Object class which is the base class for all the classes in Java. We will learn about different methods in the Object class.

In Java the base class or parent class or super class for all other classes is the Object class. This Object class provides the common functionality for all other objects.

 

Object Class Methods

Following are different methods provided by the Object class:

clone() method

This method is used to create a new object which is same as the object being cloned. Syntax of this method is as follows:

Object clone()

equals() method

This method is used to determine whether one object is same as the other object. Syntax of this method is as follows:

boolean equals(Object obj)

finalize() method

This method is used to write resource clean up code when the object is just to be garbage collected. Syntax of this method is as follows:

void finalize()

getClass() method

This method is used to obtain the class of an object at run-time. Syntax of this method is as follows:

Class getClass()

hashCode() method

This method is used to return the unique number (hash code) associated with an object. Syntax of this method is as follows:

int hashCode()

notify() method

This method is used to resume the execution of a thread waiting on the invoking object. Syntax of this method is as follows:

void notify()

notifyAll() method

This method resumes the execution of all the threads waiting on the invoking object. Syntax of this method is as follows:

void notifyAll()

toString() method

This method is used to return a string that describes the object. Syntax of this method is as follows:

String toString()

wait() method

This method is used to make an object wait on another thread of execution. Syntax of this method is as follows:

void wait()

void wait(long milliseconds)

void wait(long milliseconds, int nanoseconds)

In the above mentioned methods getClass(), notify(), notifyAll() and wait() are declared as final. So these methods cannot be overridden.

Note: Do you have a question on this article or have a suggestion to make this article better? You can ask or suggest us by filling in the below form. After commenting, your comment will be held for moderation and will be published in 24-48 hrs.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll Up
Thank you for visiting startertutorials.com! If you like this website do share with your friends by clicking on the social icons available on the left hand side.

As the domain name is quite large to remember, use this short domain to visit this site. Short domain: stuts.me