Sobes.tech
Junior — Middle

What methods and properties are available through the Object class in Java and inherited by all classes?

sobes.tech AI

Answer from AI

The Object class in Java is the root of the class hierarchy from which all other classes inherit. It provides basic methods available to all objects:

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

These methods provide basic functionality that can be overridden in your classes for application needs.