Don't let the Lockdown slow you Down - Enroll Now and Get 3 Course at 24,999/- Only. Explore Now!

General

Object Class in Java

Object Class in Java

Object Class in Java

This class is present in java.lang package. It’s direct or indirectly used to be derived in each java class. If any class extended any other Class then it will be indirectly derived else direct.

Object class has below methods

  • toString() Method
  • hashCode() Method
  • equals(Object obj) Method
  • getClass() method
  • finalize() method
  • clone() method
  • wait(), notify() notifyAll() Methods

toString() Method:

It’s provide string representation or convert object to string form. you can override toString() method to get your own String representation of objects.

public String toString()
{
// Can override and give own definition
}

hashCode() Method:

It’s generate unique hashcode for each object. The main advantage of saving objects. It’s used to override for user defined objects for better performance like searching.

equals(Object obj) Method:

It’s used to compare the two objects dynamically.

getClass() Method:

It’s return runtime class object and used to get metadata information as well.

finalize() method:

This method call required to perform garbage collector.

clone() method:

It used to create the copy or clone of object.

wait(), notify() notifyAll() Methods:

These are used in multithreading.

Click Here-> Get Java Training with Real-time Projects

Scroll Up
Besant Technologies WhatsApp