The Object class is the parent/base class of all the classes in java by default.
An object class can be used in upcasting. If you don’t know the type of any object we can use Object class to refer that object.
Let’s take an example, there is getObject() method that returns an object but it can be of any type like Organisation , Branch, etc, we can use Object class reference to refer that object. For example:
In Object class we have total nine methods which are mentioned below:
clone() – This method creates and returns a copy of the current object.
equals() – This method indicates whether some other object is “equal to” current one.
finalize() – This method is called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
getClass() – This method will return the runtime class of an object.
hashCode() – This method will return a hash code value for the object.
notify() – This method wakes up a single thread which is waiting on current object’s monitor.
notifyAll() – this method wakes up all threads that are waiting on current object’s monitor.
toString() – This method will return a string representation of the object.
wait() – This method will make current thread to wait until another thread invokes the notify() method or the notifyAll() method for the current object.