Method Description
public final Class getClass() Retrieves the Class object associated with the instance.
public int hashCode() Computes and returns a unique hash code for this object.
public boolean equals(Object obj) Determines whether this object is equal to another object.
protected Object clone() Generates and provides a shallow copy of this object.
public String toString() Offers a string representation of this object.
public final void notify() Awakens a single thread waiting on this object.
public final void notifyAll() Awakens all threads waiting on this object.
public final void wait(long timeout) throws Directs the current thread to wait until another thread triggers
InterruptedException the notify() or notifyAll() method for this object.
public final void wait(long timeout, int nanos) Instructs the current thread to wait until another thread invoke
throws InterruptedException the notify() or notifyAll() method for this object.
public final void wait() throws Prompts the current thread to wait until another thread invoke
InterruptedException the notify() or notifyAll() method for this object.
Executes when the garbage collector identifies no more refere
protected void finalize() throws Throwable
signaling its readiness for collection.
Conclusion
1. The Object class in Java serves as the foundation for all classes, directly or
indirectly.
2. All Java classes inherit methods from the Object class, making it the root of
the inheritance hierarchy.
3. Key methods of the Object class
include toString(), hashCode(), equals(), clone(), getClass(), finalize(), wait(
), notify(), and notifyAll().
4. Overriding methods like toString() and hashCode() allows customization of
behavior for specific classes.
5. The finalize() method provides an opportunity for cleanup tasks before an
object is garbage collected.
6. Understanding and utilizing Object class methods are essential for effective
Java programming and memory management.