So now you want to actually show you how you can use these protected access modifier.
OK.
But always use the getters and setters in order to access the values of the instance variables.
OK so a name as you can see name and then put into double quotes here color and then I actually put
another plus operator here.
And then again I can actually refer to the name of the color instance variable plus.
And then again I put two double quotes here.
So speed.
OK.
And that puts a plus operator here.
Amount of speed.
And then I put another plus operator here and I put two double quotes here.
Power and then and then I put a plus operator here amount of power.
OK.
As you can see now this is going to actually turn these values.
OK.
So let's actually inside this our main activity that job I find here is instead of just calling these
two string method.
I can't call that out.
Put some values to the screen Nevitt.
OK.
So let's actually run our project and see what happens.
So as you can see here these are the values that are outputted to the screen.
OK name my chat.
So let's actually go inside this Chatz class here as you can see Name Is My chat's color is white and
speed.
As you can see he's 40 and power is 50.
OK.
And let's actually go ahead and actually put our implementation's inside this lower class.
OK.
So now let me actually point out that always allow other classes to access your instance variables by
using the getters and setters.
OK.
So let's actually change these protected access modifiers to privates because in this way our codes
are more secure.
OK.
And we can actually restrict the access to these instance variables by just creating getters and setters
so that other classes can not directly access these private parts.
OK.
So hopefully that makes sense.
And let's go actually inside this lion class.
And as you know the lion is actually part of the it's actually part of the Chadha family animals.
OK.
So we can actually say that a lion is a cat's OK extends Chatz OK.
So as you can see here now our lion class is actually inheriting all of the features and behaviors that
are inside this cat class.
OK.
So here inside this class I can actually create some instance variables that are only special to display
in class.
For example Ilyin is a brave animal.
So I can actually create a boolean variable private boolean is brai OK.
And then I.
And then I put a semicolon at the end of this statement here.
OK.
So now as you can see these are characteristic is only specific to display in class.
OK.
So here I can actually create a constructor for this class.
So first of all I need to actually put the public access modifier here and then I need to actually specify
the name of my constructor for this line class.
So the name of this constructor must be the same as the name of this line class.
OK.
Lion.
And then I put up around brackets after my constructor name and then I open and close my constructor
by using these curly braces.
So inside the prentices as you can see we need to actually specify some arguments.
Otherwise the Android studio is going to actually complain.
Let's actually cover our mouse pointer over this error area.
There is no default constructor available in chat class as you can see that example that Matas I saw
that that app for that chat.
So let's go actually inside this math class as you can see we've got our custom constructor inside this
class.
OK.
There is no default constructor.
So we need to actually initialize the constructor that is inside this class because we are inheriting
the behaviors and features that are inside that class.
OK.
So here I can just typing super And then inside Apprentice's I need to actually pass these values up.
Name Caller amount of speed.
Amount of power or number of legs and can hunt other animals which is a boolean value.
OK so here I can actually specify some arguments for this constructor.
OK.
So that whenever we actually create an object from this lower class we need to pass those values to
the constructor OK.
So the first value is going to be the name.
OK so strange name.
And the second argument is again color and our first argument is of type int and the name of that argument
is amount of speed.
Ok comma in that amount of power comma.
So let's actually go inside this cat class in order to see other values other arguments so name caller
amount of speed.
Amount of power a number of legs can hunt other animals.
OK.
Int number of legs.
OK.
Boullion can haunt other animals.
OK.
So let's actually create a new line here in order to actually see these are arguments better.
OK.
And we have another instance variable which is specific.
Only two these are like in class.
OK.
Is brief.
So boolean is brave.
OK.
So here in say the apprentice's of the superhero I can just pass these values.
OK.
Name comma color comma amount of speed comma and out of power comma.
Number of Lex comma and can hunt other animals.
OK.
So as you can see here these are the arguments.
These are the values that we specified for this chat class.
OK.
As you can see here these are the arguments that we specified for this cat class yet he conceived for
this for the constructor of this Kathe Class VI is specified these arguments.
Ok name caller amount of speed.
Amount of power number of legs and can hunt other animals.
So because this lion class is actually inheriting all of those are features and behaviors that are inside
this cat class into this lion class here.
We need to actually initialize the constructor of the superclass.
OK so this super refers to this chat class here.
OK.
And we need to actually first of all initialize the constructor of this class and then we can actually
initialize our own instance variable here.
So first I just need to type in this in order to refer to this lower class that is brief assignment
operator and here I can I truly referred to this argument here.
OK it is brave.
Now as you can see I initialized my own r instance variable here my own instance variable inside this
line class OK.
And here in this line of code I initialized the constructor of the superclass.
OK so that I don't need to actually redeclare these instance variables inside this class.
So again that's the power of inheritance with just one line of code.
We actually managed to initialize all all of these instance variables OK and we didn't declare these
instance variables and we just inherited all of these instance variables and we can use them.
OK.
And I can actually create a set here and I'll get her Meffert for this is brave instance variable.
Again I'd like to clear out of this constructor here and inside this in class I wrote click here and
then I click on generate and then I click on get her and set her and here choose this is brave instance
variable here and then click on OK.
OK.
So as you can see here this is our Get here for this instance variable is brave.
And this is our set here for this instance variable.
So I don't like this name here is brave.
So let's actually change this number to get brave.
OK.
So hopefully that makes sense.
And now I want to actually override the twisting method that I actually inherit from the Object class.
OK.
So I just need to type in here two was three.
Now we can actually override this method.
So let's actually delete this line of code here.
We can actually inherit the implementations that are inside this Kathe class here.
OK.
As you can see we did actually put this code here.
So now we can actually use this code inside this line class by just typing in return super dot to think.