From the course: Object-Oriented Programming with Java

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

The mother of all objects

The mother of all objects

- [Instructor] Here, I have a class ExtraRandom that extends Random. I'm going to you show what its type hierarchy looks like. Okay, so you can see that ExtraRandom class has this method nextLetter, but it also inherits a bunch of stuff from the Random class. So a lot of these methods will also be part of ExtraRandom. What's this thing up here? Well, that's the class Object, and she is the mother of all Java objects. It's the only class in Java that doesn't extend another class. You might recognize some of these, probably the toString method. It gets called every time you do a System.out.print or println and you have an object in there. What it's doing magically in the background is it's calling the toString method of Object unless you override the toString method. I'm also going to draw this relationship as a class diagram. Classes are usually drawn like this. So we have the name at the top. This is going to be…

Contents