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 obj for equality.
  • finalize(): Called by the garbage collector before the object is destroyed.
  • getClass(): Returns the Class object that describes the class of the object.
  • hashCode(): Returns the hash code of the object.
  • 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.
  • wait(): The calling thread enters the waiting state until notify(), notifyAll(), or the timeout expires.
  • wait(long timeout): Same as wait(), but with a timeout in milliseconds.
  • wait(long timeout, int nanos): Same as wait(long timeout), but with more precise timing (nanoseconds).