The java.lang.Object class

So, here is a surprise. Each Java class, by default (without an explicit declaration), extends the class Object. To be precise, it is java.lang.Object, but we have not introduced packages yet and will only be talking about them in Chapter 7Packages and Accessibility (Visibility).

All Java objects inherit all the methods from it. There are ten of them:

Let's briefly visit each of these methods.

Before we do that, we would like to mention that you can override their default behavior in your classes, and re-implement them any way you need, which programmers often do. We will explain how to do this in Chapter 6, Interfaces, Classes, and Objects Construction.