The Object class, which is the base class for all classes in Java, is included in the java.lang package and has 13 methods.

Object()

Object class constructor, (non-key)

registerNatives()

In order for the JVM to discover native functionality, they are named in a certain way. For example, for Java. Lang. Object. RegisterNatives, corresponding C function named Java_java_lang_Object_registerNatives.

By using registerNatives (or more specifically, the JNI function registerNatives), you can name any C function you want. (Not important)

clone()

The clone() function is used to save an existing object. Only implements the Cloneable interface can call this method, otherwise throw CloneNotSupportedException anomalies. (Note: This may lead to questions about design patterns.)

getClass()

Final method, used to get the type of the runtime. This method returns the Class/runtime Class of this Object. The effect is the same as object.class. (Note: the answer to this question may lead to the class loading, reflection, etc.)

equals()

Equals is used to compare whether the contents of two objects are equal. By default (inherited from the Object class), equals and == are the same unless overridden. (Note: this may lead to the more common question of “equals vs. ==” and how hashMap works.)

hashCode()

This method is used to return the physical address (hash value) of the object on which it resides, and is often overridden with equals to ensure that equal objects have equal Hashcodes. (Again, the question that might lead to the implementation of hashMap)

toString()

The toString() method returns a string representation of the object

wait()

Causes the current thread to wait until another thread calls notify() or notifyAll() on this object. What is the difference between wait and sleep?

wait(long timeout)

Causes the current thread to wait until another thread calls notify() or notifyAll() on this object, or the specified amount of time is exceeded. What is the difference between wait and sleep?

wait(long timeout, int nanos)

Causes the current thread to wait until another thread calls notify() or notifyAll() on this object, or until some other thread interrupts the current thread, or until an actual amount of time has elapsed. What is the difference between wait and sleep?

notify()

Wakes up a single thread waiting on this object monitor. (Thread communication)

notifyAll()

Wakes up all threads waiting on this object monitor. (Thread communication)

finalize()

This method is called by the object’s garbage collector when the garbage collector determines that no more references to the object exist. (Not the point, but be careful to introduce the garbage collection question)