Sobes.tech
Junior — Middle

Can you list the methods provided by the Object class in Java?

sobes.tech AI

Answer from AI

In Java, the Object class provides basic methods that are inherited by all classes:

  • equals(Object obj) — compares objects for equality.
  • hashCode() — returns the hash code of the object, used in collections.
  • toString() — returns a string representation of the object.
  • getClass() — returns the Class object describing the class of the object.
  • clone() — creates a copy of the object (requires implementation of the Cloneable interface).
  • finalize() — called before garbage collection (deprecated method).
  • wait(), notify(), notifyAll() — methods for thread work and synchronization.

These methods provide basic functionality for all objects in Java.