When we create any class, we extend and reuse class java.lang.Object. The class Object defines code to take care of all the threading and object-locking issues, together with providing default implementation for methods like toString(), hashCode(), and equals(). Method toString() returns a textual description (String) of an instance. Methods like hashCode() and equals() enable objects to be stored and retrieved efficiently in hash-based collection classes like HashMap. What do you think would happen if class java.lang.Object was defined as an interface? In this case, you’d need to implement all these methods for every class that you created. But it’s not useful to replicate this type of boilerplate code across many implementation classes. So class inheritance comes in handy here.