1
00:00:00,720 --> 00:00:07,620
So in this way we did manage to concatenate these two string values together and here as you can see

2
00:00:07,620 --> 00:00:10,920
in the emulator these values are together here.

3
00:00:10,930 --> 00:00:11,600
OK.

4
00:00:11,610 --> 00:00:13,300
The name of my child is my child.

5
00:00:13,380 --> 00:00:18,630
So let's actually go inside this main activity that Java here as you can see the name of my child is

6
00:00:18,630 --> 00:00:24,750
my charts the color of my child is white the speed of my child is 40.

7
00:00:24,750 --> 00:00:31,660
The power of my child is 40 and the number of legs of my child is four and fight two.

8
00:00:31,770 --> 00:00:33,810
So hopefully that makes sense.

9
00:00:33,870 --> 00:00:40,880
And here inside is Kathe class as you can see of vidit use the power of inheritance in our class.

10
00:00:41,040 --> 00:00:41,680
OK.

11
00:00:41,970 --> 00:00:45,960
So please make sure that you write your codes in this way.

12
00:00:46,110 --> 00:00:51,870
If you want to be a professional and whatever will appear or if you want to actually apply for your

13
00:00:51,990 --> 00:00:59,650
dream job as an Android Developer and actually earn top money please write your code in this way.

14
00:00:59,670 --> 00:01:06,540
You need to actually to write your cards in this way in order to persuade the employers to employ you.

15
00:01:06,650 --> 00:01:07,160
OK.

16
00:01:07,200 --> 00:01:13,060
If you write your code in this way everybody wants you to write that applications.

17
00:01:13,080 --> 00:01:13,570
OK.

18
00:01:13,650 --> 00:01:18,480
Because this way of writing code is the most professional way of writing good code.

19
00:01:18,510 --> 00:01:18,960
OK.

20
00:01:19,170 --> 00:01:25,090
So now let's actually go inside this Animal class and here let's actually create another method.

21
00:01:25,110 --> 00:01:25,750
OK.

22
00:01:26,040 --> 00:01:32,880
So the access modifier of this method is public and the return type of this method is it and the name

23
00:01:32,880 --> 00:01:38,880
of this method is evaluate Alamein value.

24
00:01:39,560 --> 00:01:40,330
OK.

25
00:01:40,650 --> 00:01:43,670
And that I put a pair of brackets after the name of that name.

26
00:01:43,680 --> 00:01:48,030
And then I open and close the Smurfette by using these curly braces.

27
00:01:48,030 --> 00:01:53,580
So now I want to actually return a value that specifies the animal's value.

28
00:01:53,630 --> 00:01:59,730
OK first let's actually create an integer variable and the name of this variable is the result.

29
00:01:59,880 --> 00:02:07,560
And then I put an assignment operator here and then I specify the value of our animal by actually multiplying

30
00:02:07,680 --> 00:02:14,460
the value of this amount of speed instance variable by the value of this amount of power instance variable.

31
00:02:14,460 --> 00:02:14,940
OK.

32
00:02:15,180 --> 00:02:22,620
So amount of speed instance variable multiplied by amount of power instance variable.

33
00:02:22,950 --> 00:02:26,240
And then I return disvalue return result.

34
00:02:26,720 --> 00:02:31,980
OK so now as you can see we've got this method inside this animal class and this cad's class actually

35
00:02:31,980 --> 00:02:38,060
inherits all of the features and behaviors that are declared as public.

36
00:02:38,310 --> 00:02:39,670
Inside the Animal class.

37
00:02:39,690 --> 00:02:40,290
OK.

38
00:02:40,620 --> 00:02:42,900
So I can actually access that method here.

39
00:02:43,140 --> 00:02:43,670
OK.

40
00:02:43,830 --> 00:02:45,680
So let's actually access that method.

41
00:02:45,900 --> 00:02:50,920
And here we can actually again concatenate this value here with another value.

42
00:02:51,140 --> 00:02:55,560
So plus operator evaluates animal value.

43
00:02:56,070 --> 00:02:57,060
OK.

44
00:02:57,480 --> 00:03:02,200
So as you can see here we did manage to concatenate this value with other strings here.

45
00:03:02,220 --> 00:03:02,520
OK.

46
00:03:02,520 --> 00:03:09,540
So as you can see here inside this Animal class the Smurfette returns a value of type integer and in

47
00:03:09,540 --> 00:03:15,280
Java we can actually concatenate string values with integer values.

48
00:03:15,300 --> 00:03:16,050
OK.

49
00:03:16,260 --> 00:03:21,810
So as you can see here we poods this plus operator in order to concatenate is string value.

50
00:03:22,000 --> 00:03:27,040
With this we have returned value of the Smurfit evaluate animal value.

51
00:03:27,180 --> 00:03:28,340
And if I had on my project.

52
00:03:28,350 --> 00:03:30,130
Now let's see what happens.

53
00:03:30,270 --> 00:03:33,210
So as you can see here now this value is outputted here.

54
00:03:33,210 --> 00:03:33,650
OK.

55
00:03:33,720 --> 00:03:34,860
Twelve hundred.

56
00:03:35,100 --> 00:03:35,990
OK.

57
00:03:36,330 --> 00:03:42,930
So at least 12 hundred is the result of multiplication of these are two numbers.

58
00:03:42,930 --> 00:03:45,420
Number 40 multiplied by number 30.

59
00:03:45,720 --> 00:03:53,490
OK so this number 40 here is the value of this speed amount of speed instance variable and this number

60
00:03:53,490 --> 00:04:00,090
first here is the value of this power instance variable and we multiplied these two values together

61
00:04:00,150 --> 00:04:04,240
in order to actually specify the animal's value.

62
00:04:04,240 --> 00:04:05,360
OK twelve hundred.

63
00:04:05,430 --> 00:04:06,170
OK.

64
00:04:06,420 --> 00:04:13,980
So here I can actually inside this math class I can actually specify what this number relates to by

65
00:04:13,980 --> 00:04:18,020
just actually putting another plus operator here.

66
00:04:18,150 --> 00:04:23,040
And then I can put a strain of value here a string literal.

67
00:04:23,220 --> 00:04:30,330
And here I can't just save an animal value OK or chat's value.

68
00:04:30,330 --> 00:04:31,510
It doesn't really matter.

69
00:04:31,620 --> 00:04:36,190
And then I can actually put in a call in here and another space here.

70
00:04:36,210 --> 00:04:41,380
And let's actually put another space here in order to separate these values here.

71
00:04:41,580 --> 00:04:44,580
So let's actually run our project again and see what happens.

72
00:04:44,760 --> 00:04:45,060
OK.

73
00:04:45,060 --> 00:04:49,320
As you can see now disvalue is outputted Hiroki animal value.

74
00:04:49,380 --> 00:04:50,390
Twelve hundred.

75
00:04:50,550 --> 00:04:51,370
OK.

76
00:04:51,660 --> 00:04:53,340
So hopefully that makes sense.

77
00:04:53,490 --> 00:04:57,840
And now we want to actually talk about another axis modifier.

78
00:04:57,930 --> 00:05:05,770
So inside this animal pass as you can see we've got these are private instance variables and this math

79
00:05:05,770 --> 00:05:14,500
class which inherits all of those instance variables and methods I cannot see those private instance

80
00:05:14,500 --> 00:05:15,260
variables.

81
00:05:15,370 --> 00:05:15,930
OK.

82
00:05:16,060 --> 00:05:17,670
So there is a solution for that.

83
00:05:17,800 --> 00:05:18,390
OK.

84
00:05:18,430 --> 00:05:27,100
You can actually use the protected access modifier in order to allow the subclasses or the classes that

85
00:05:27,130 --> 00:05:34,250
inherit from this class to actually access these instance variables.

86
00:05:34,330 --> 00:05:36,060
So let's see how we can do that.

87
00:05:36,370 --> 00:05:37,490
OK everyone.

88
00:05:37,490 --> 00:05:42,100
Now as you can see this instance variables are declared as private.

89
00:05:42,100 --> 00:05:43,570
Instance variables are OK.

90
00:05:43,780 --> 00:05:48,090
The access modifier of this instance variables is private.

91
00:05:48,370 --> 00:05:51,750
So inside this Kathe class you might actually create another method.

92
00:05:51,760 --> 00:05:52,140
OK.

93
00:05:52,340 --> 00:06:00,850
Public stream the return type of this method is strange and the name of this line if it is our poods

94
00:06:01,960 --> 00:06:05,720
some values to the screen.

95
00:06:06,390 --> 00:06:08,490
Ok for example.

96
00:06:08,890 --> 00:06:15,490
And then I put up around brackets after my method name and then I open and close my method by using

97
00:06:15,490 --> 00:06:16,950
these curly braces.

98
00:06:16,960 --> 00:06:22,040
So inside the Smurfette I want to actually put my own implementations inside the Smurfette.

99
00:06:22,050 --> 00:06:22,460
OK.

100
00:06:22,600 --> 00:06:27,980
So here I can just type in return and then I can just put these two double quotes here.

101
00:06:28,210 --> 00:06:32,240
So as you can see here we need to actually return a value of types three in here.

102
00:06:32,260 --> 00:06:35,860
Ok this may affect the return type of the Smif it is string.

103
00:06:36,040 --> 00:06:44,650
So return and as against the inside of double quotes I can just type in name colon and then plus operator

104
00:06:44,890 --> 00:06:51,070
and then I want to actually to access the name instance variable that is declared inside this Animal

105
00:06:51,070 --> 00:06:51,360
class.

106
00:06:51,370 --> 00:06:51,850
OK.

107
00:06:52,000 --> 00:06:58,900
So as you know this math class here is actually inheriting all of the features and behaviors that are

108
00:06:58,900 --> 00:07:00,250
inside this Animal class.

109
00:07:00,370 --> 00:07:06,450
So you can actually access the instance variables that are inside this animal class.

110
00:07:06,700 --> 00:07:14,830
But because this instance variables are declared as private I cannot see this instance variables these

111
00:07:15,130 --> 00:07:18,630
instance variables are still part of this chat class.

112
00:07:18,670 --> 00:07:20,670
OK but I cannot see them.

113
00:07:20,820 --> 00:07:21,480
OK.

114
00:07:21,580 --> 00:07:29,140
When you declare your instance variables or your methods as private data class that contains all those

115
00:07:29,140 --> 00:07:34,480
private parts has complete control over those private parts of that class.

116
00:07:34,480 --> 00:07:34,940
OK.

117
00:07:35,080 --> 00:07:42,080
So this animal class actually has complete control over these private instance variables and this cat

118
00:07:42,080 --> 00:07:48,190
class can not see those are private parts that are inside this Animal class.

119
00:07:48,190 --> 00:07:54,040
So here in this chat class inside this output some values to the screen Meffert.

120
00:07:54,250 --> 00:07:58,560
You want to actually access the value of the name instance variable.

121
00:07:58,600 --> 00:08:00,650
I can just typing get a name.

122
00:08:00,730 --> 00:08:08,530
OK so are I assure you that you can actually use our diskettes name in order to access the value of

123
00:08:08,530 --> 00:08:10,050
the named instance variable.

124
00:08:10,210 --> 00:08:17,080
But there is another way that we can actually access those private parts of that class.

125
00:08:17,080 --> 00:08:17,550
OK.

126
00:08:17,710 --> 00:08:23,860
So as you can see here this Animal class in this Animal class these are the private parts we have and

127
00:08:23,860 --> 00:08:27,030
other our access modifier called Protector's.

128
00:08:27,150 --> 00:08:32,430
OK protected this protected access modifier is just like private's.

129
00:08:32,500 --> 00:08:40,720
It actually allows the subclasses of this superclass this animal class to access these private parts

130
00:08:40,810 --> 00:08:43,200
that are inside of this animal class.

131
00:08:43,360 --> 00:08:44,040
OK.

132
00:08:44,260 --> 00:08:51,520
So inside this cat class I can just refer to the name instance variable that is declared inside this

133
00:08:51,610 --> 00:08:56,440
animal class because I use this protected access modifier.

134
00:08:56,500 --> 00:09:03,580
So this access modifier actually allows us actually allows other classes that are subclasses of this

135
00:09:04,030 --> 00:09:08,200
animal class to access these instance variables.

136
00:09:08,200 --> 00:09:08,710
OK.

137
00:09:08,770 --> 00:09:11,990
Only subclasses can access this instance variable.

138
00:09:12,160 --> 00:09:19,660
Ok the cat class is actually related to this animal class so I can actually access this named instance

139
00:09:19,660 --> 00:09:25,540
variable OK because we are inheriting all of the features and behaviors that are inside these Animal

140
00:09:25,540 --> 00:09:26,120
class.

141
00:09:26,140 --> 00:09:26,750
OK.

142
00:09:27,010 --> 00:09:33,660
So let's actually change the access modifier of Ds are instance variables to protected.

143
00:09:33,670 --> 00:09:35,780
And here I can just take and protected.

144
00:09:36,070 --> 00:09:38,300
And here again just like in Protector's.

145
00:09:38,680 --> 00:09:39,500
OK.

146
00:09:39,880 --> 00:09:41,950
And then inside is chat's class as you can see.

147
00:09:41,950 --> 00:09:46,360
Now I can actually access those instance variables directly.

148
00:09:46,360 --> 00:09:46,910
OK.

149
00:09:47,260 --> 00:09:53,810
But this is not the proper way to allow other classes to access your instance variables.

150
00:09:53,950 --> 00:09:54,400
OK.

151
00:09:54,490 --> 00:10:02,490
Always allow the other classes to access the value of your variables by using those getters and setters.

152
00:10:02,520 --> 00:10:02,960
OK.

