Sobes.tech
Junior

What methods does the Object class have in Java?

sobes.tech AI

Answer from AI

  • clone(): creates and returns a copy of the object.
  • equals(Object obj): compares the current object with another object for equality. By default, compares references.
  • finalize(): called by the garbage collector before destroying the object. Deprecated, not recommended for use.
  • getClass(): returns the Class object representing the class of the object.
  • hashCode(): returns the hash code of the object. Used in hash tables.
  • notify(): resumes the execution of one thread waiting on the object's monitor.
  • notifyAll(): resumes the execution of all threads waiting on the object's monitor.
  • toString(): returns a string representation of the object. By default, returns the class name and hash code.
  • wait(): causes the current thread to wait until notify() or notifyAll() is called.
  • wait(long timeoutInMillis): causes the current thread to wait for the specified time or until notify() or notifyAll() is called.
  • wait(long timeoutInMillis, int nanos): causes the current thread to wait for the specified time with higher precision.
What methods does the Object class have in Java… - sobes.tech