1

00:00:01,110  -->  00:00:08,700
Let's not look at the most fundamental class in Java because the object plus object glass is considered

2

00:00:08,820  -->  00:00:10,920
as the mother of all.

3

00:00:11,160  -->  00:00:19,050
And by that we mean that it is the superclass or her writing that is every class directly or indirectly

4

00:00:19,380  -->  00:00:22,890
and implicitly extends the Object class.

5

00:00:23,010  -->  00:00:28,200
For example we know that the user class is the top most class in our inheritance tree.

6

00:00:28,710  -->  00:00:33,830
So use that class directly and also implicitly extends the Object class.

7

00:00:34,050  -->  00:00:38,960
Who are the staff class also extends object but it does that in an indirect way.

8

00:00:39,120  -->  00:00:43,680
The other use a class since object class is a fundamental class.

9

00:00:43,770  -->  00:00:50,340
We know that it should be in the OR doglike package and there are two reasons for having the Object

10

00:00:50,340  -->  00:00:51,260
class.

11

00:00:51,270  -->  00:00:54,350
First one is that it acts as a polymorphic.

12

00:00:54,870  -->  00:01:02,120
That is you can assign any Jawa object to a variable whose reference type is Object class Unadilla job

13

00:01:02,190  -->  00:01:09,300
designers who create classes with methods that would pick any type that never existed when the first

14

00:01:09,310  -->  00:01:11,420
produced Garces.

15

00:01:11,460  -->  00:01:17,670
Second reason is it I think several code methods that are inherited by every class since the object

16

00:01:17,670  -->  00:01:25,110
class is the most super class on some of these methods can be used directly or can be overridden while

17

00:01:25,110  -->  00:01:30,530
others are Margret's whiner which means that they cannot be overridden.

18

00:01:30,540  -->  00:01:35,600
Now let's look at some of the most frequently used methods in the Object class.

19

00:01:35,610  -->  00:01:42,030
First one is the string method and as a name so just ignore it and say string representation of the

20

00:01:42,030  -->  00:01:43,310
object.

21

00:01:43,710  -->  00:01:48,830
And by default it includes the class name on some weird number as we can see here.

22

00:01:48,870  -->  00:01:53,570
In the case of stuff class let me just show this in the code.

23

00:01:54,630  -->  00:02:01,710
OK here we are creating a staff instance and we're simply printing out stuff got to string so we are

24

00:02:01,710  -->  00:02:07,630
invoking the string method on the staff reference so then I ran it.

25

00:02:07,640  -->  00:02:13,170
It just bends the staff class name followed by this weird number.

26

00:02:13,620  -->  00:02:16,000
So let's just go back.

27

00:02:16,700  -->  00:02:18,710
I come in from Effective Java.

28

00:02:18,840  -->  00:02:23,690
Actually it recommends to always override that boosting matter.

29

00:02:24,030  -->  00:02:30,600
And the reason is it is very useful for debugging and boosting is automatically in-road when the object

30

00:02:30,600  -->  00:02:34,790
reference is passed to the system dot dot Pentlands me.

31

00:02:35,070  -->  00:02:38,550
That is you don't have to invoke the string method explicitly.

32

00:02:38,610  -->  00:02:42,510
The printed matter does it automatically.

33

00:02:42,720  -->  00:02:47,970
The item also recommends that this mother children and all of the interesting information contained

34

00:02:47,970  -->  00:02:49,420
in the object.

35

00:02:49,470  -->  00:02:56,700
Let me also show this where the staff object in our class me just common default.

36

00:02:57,610  -->  00:03:03,140
Let me just uncommon this display use that info which was used in one of the previous day.

37

00:03:03,240  -->  00:03:12,810
So it's just going to the user class and the User class I'm HAVERTON this goosestepping matter.

38

00:03:13,800  -->  00:03:18,360
Just don't worry about this and not in it's quality and notation under Chancellery want.

39

00:03:18,600  -->  00:03:23,640
So the posting that there simply prints the data the attributes.

40

00:03:23,670  -->  00:03:29,050
So this whole piece of code was previously inside that display user informatic.

41

00:03:29,340  -->  00:03:34,810
So we are right we have it and disgusting method and this glue string method actually what right the

42

00:03:35,040  -->  00:03:43,410
string method in the superclass in the object class which is the superclass of user and display in the

43

00:03:43,410  -->  00:03:47,120
display use informatively or simply passing this object.

44

00:03:47,220  -->  00:03:52,950
And then we pass this the print Ellenwood automatically invoke the string method it wanted this dark

45

00:03:52,950  -->  00:03:59,690
blue string and at that instance this method would be invoked and this distinguished get printed.

46

00:03:59,760  -->  00:04:03,840
So we had this entire string inside display use info earlier.

47

00:04:03,850  -->  00:04:10,230
Now we are we have changed the implementation so that it would involve the two string matter.

48

00:04:10,410  -->  00:04:17,780
So let me just go ahead and run this as you can see it is amending the user info on its printing border

49

00:04:17,910  -->  00:04:21,210
attributes in the class.

50

00:04:21,600  -->  00:04:23,600
Next is a hash code matter.

51

00:04:24,090  -->  00:04:29,670
Undertreatment something called hash quote off an object which is basically the objects memory address

52

00:04:29,770  -->  00:04:31,800
and hexadecimal one.

53

00:04:32,550  -->  00:04:36,820
So two object differences pointing to the same object will have the same high score.

54

00:04:37,180  -->  00:04:43,050
And as you can see here the staff object is being referenced by two object references on both of them

55

00:04:43,310  -->  00:04:50,220
have identical hash codes and this method is supported for the benefit of hash tables which we will

56

00:04:50,220  -->  00:04:52,980
discuss in the collections framework chapter.

57

00:04:53,460  -->  00:04:56,050
Let's look at this method in code.

58

00:04:57,090  -->  00:05:03,090
So here we have the staff instance and we are simply printing the hash code and then we are creating

59

00:05:03,090  -->  00:05:04,850
a new area be able call staff.

60

00:05:04,920  -->  00:05:07,250
And we are assigning the same reference to it.

61

00:05:07,260  -->  00:05:09,940
So this way both of them refer to the same object.

62

00:05:09,960  -->  00:05:17,280
And when we opened the hash code for staff too it should be same as staff as a hash court for stuff

63

00:05:17,280  -->  00:05:17,810
.

64

00:05:17,820  -->  00:05:20,000
So let me run this.

65

00:05:20,250  -->  00:05:24,730
And as you can see both of them have the same high score.

66

00:05:25,350  -->  00:05:26,920
Next is equal to murder.

67

00:05:27,350  -->  00:05:32,840
And it compares two objects for equanimity and accrue if they are equal.

68

00:05:33,300  -->  00:05:39,090
So it compares the object on which the matter is invoked to the object that just passed us argument

69

00:05:40,490  -->  00:05:44,240
and by default this method uses the equality operator.

70

00:05:44,240  -->  00:05:50,600
You may recall the equality operator when applied on object references would return accrue only if both

71

00:05:50,670  -->  00:05:53,770
the object or Francis refer to the same object.

72

00:05:54,540  -->  00:06:01,320
But sometimes two different objects may be logical equaling that is and how identical contents.

73

00:06:01,470  -->  00:06:03,540
But they're still two different objects.

74

00:06:03,540  -->  00:06:05,550
Like in the example shown here.

75

00:06:05,730  -->  00:06:11,660
Here we have two different user objects which are initialized at the same ID and name.

76

00:06:11,820  -->  00:06:17,190
So they are logically equal and on Indicus up just like Haast tables you would want to create such kind

77

00:06:17,190  -->  00:06:19,630
of objects as equal.

78

00:06:19,770  -->  00:06:25,950
In that case you would have to override the equals method thereby overwriting its default behavior of

79

00:06:25,950  -->  00:06:28,040
using the equality operator.

80

00:06:28,890  -->  00:06:35,640
In this example you could add an equals method in the User class as shown here here only ID field is

81

00:06:35,640  -->  00:06:40,310
used as typically ID feels uniquely identify objects.

82

00:06:40,410  -->  00:06:47,760
Note is that the user parameter has to be Doncaster KREM object to use a class in order to use the get

83

00:06:47,760  -->  00:06:52,960
ID method as obviously Object class will not have this method.

84

00:06:53,030  -->  00:06:57,960
Next is the get class metric and it is basically a final method.

85

00:06:58,060  -->  00:07:03,960
And they did and something called a class object which encapsulates all the Mattei information about

86

00:07:03,960  -->  00:07:10,910
the class that is a class off the object on which this method is in work and meta information would

87

00:07:10,910  -->  00:07:15,670
include details like the class name superclass name method names and so on.

88

00:07:15,900  -->  00:07:20,870
And we will discuss it in more detail when we get to the GBM in the next chapter.

89

00:07:21,390  -->  00:07:27,880
Next to the clone method and it simply returns a copy of this object that is a clone of this object

90

00:07:27,890  -->  00:07:28,430
.

91

00:07:28,770  -->  00:07:34,770
And this matter is a protected matter and it must be overridden if we want to use its functionality

92

00:07:34,780  -->  00:07:35,160
.

93

00:07:35,700  -->  00:07:38,890
But let's not worry about it for now as we will look at it soon.

94

00:07:38,940  -->  00:07:44,590
When discussing a concept called interfaces so that's about the object last.

95

00:07:44,610  -->  00:07:49,350
There are a few other interesting methods but they're related to threads and will be discussed when

96

00:07:49,350  -->  00:07:50,840
we get to concurrency.

97

00:07:51,180  -->  00:07:51,560
Thank you
