Core java tutorial for beginners
A tutorial blog which explains different core concepts related to Java along with programming examples
Subscribe to Startertutorials.com's YouTube channel for different tutorial and lecture videos.

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.

How useful was this post?

Click on a star to rate it!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Suryateja Pericherla

Suryateja Pericherla, at present is a Research Scholar (full-time Ph.D.) in the Dept. of Computer Science & Systems Engineering at Andhra University, Visakhapatnam. Previously worked as an Associate Professor in the Dept. of CSE at Vishnu Institute of Technology, India.

He has 11+ years of teaching experience and is an individual researcher whose research interests are Cloud Computing, Internet of Things, Computer Security, Network Security and Blockchain.

He is a member of professional societies like IEEE, ACM, CSI and ISCA. He published several research papers which are indexed by SCIE, WoS, Scopus, Springer and others.

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 *