1
00:00:00,270 --> 00:00:03,030
A class can inherit properties from another class.

2
00:00:05,420 --> 00:00:09,140
Every class in Java has a common ancestor, the object class.

3
00:00:13,300 --> 00:00:15,490
In this lesson, you're going to learn about inheritance.

4
00:00:18,270 --> 00:00:21,390
The object class is the ancestor of every class.

5
00:00:23,440 --> 00:00:26,350
Every class inherits methods from the object class.

6
00:00:31,790 --> 00:00:36,710
Here's the source code for the object class, it's a bit hard to read on the website, so I cleaned

7
00:00:36,710 --> 00:00:37,310
it up for you.

8
00:00:37,580 --> 00:00:41,960
So please open the folder for this lesson by navigating that this path and the resources.

9
00:00:47,780 --> 00:00:51,470
You'll notice inside the object class there's an equals method.

10
00:00:51,800 --> 00:00:56,540
Remember when I used to say that default equals method compares the references of two variables?

11
00:00:56,960 --> 00:00:59,430
This is the equals method I've been talking about.

12
00:00:59,960 --> 00:01:01,460
There's also a two string method.

13
00:01:03,630 --> 00:01:06,000
A harsh code method and a bunch of other methods.

14
00:01:08,920 --> 00:01:15,100
Get class, notify, notify all that in overloads, the wait method three times, remember that overloading

15
00:01:15,100 --> 00:01:18,630
means defining the same method more than once, but with different parameters.

16
00:01:18,940 --> 00:01:21,190
And I commented these methods for simplicity.

17
00:01:21,850 --> 00:01:25,290
OK, now what I want you to do is add another folder to your workspace.

18
00:01:25,300 --> 00:01:26,380
So follow what I'm doing.

19
00:01:31,130 --> 00:01:34,640
And grab the folder that corresponds to this path in the resources.

20
00:01:40,100 --> 00:01:45,830
OK, before we continue, I want to repeat that the object class is the common ancestor of every class,

21
00:01:46,310 --> 00:01:50,060
so every class inherits methods from the object class.

22
00:01:52,990 --> 00:01:58,120
Inside may create a new object of the person, class, person, person is equal to a new person.

23
00:02:01,390 --> 00:02:02,020
Zach.

24
00:02:04,040 --> 00:02:04,940
Who's 27?

25
00:02:11,390 --> 00:02:16,790
Now, from person noticed that we can automatically access so many methods, we can access an equals

26
00:02:16,790 --> 00:02:22,430
method, a hash code method, a two string method, wait, notify get class.

27
00:02:23,570 --> 00:02:26,730
But we didn't define any of these methods in the person class.

28
00:02:26,750 --> 00:02:27,830
So where did they come from?

29
00:02:30,310 --> 00:02:37,110
These methods came from the object class, because object is the common ancestor of every class, then

30
00:02:37,120 --> 00:02:40,090
every class person is going to inherit all of its methods.

31
00:02:41,920 --> 00:02:43,090
Here is equals.

32
00:02:44,460 --> 00:02:45,600
Here's to string.

33
00:02:47,700 --> 00:02:48,840
There is a code.

34
00:02:51,160 --> 00:02:54,970
Get class, etc. This is inheritance.

35
00:03:00,280 --> 00:03:03,790
Let's recap, a class can inherit properties from another class.

36
00:03:05,400 --> 00:03:11,970
The object class is the common ancestor of every class, so every class inherits methods from the object

37
00:03:11,970 --> 00:03:12,510
class.

