And as you can see here inside this main class here we are actually creating an object from these chat
class called Cat 1.
And here we are actually passing some values to the constructor of this cat class.
As you can see whenever we create an object from this track class the constructor of this cat class
is going to be called.
OK.
So as you can see here you are actually passing the name of this chat.
And here we are actually passing the color of this card.
The amount of speed of this card the amount of power of this card and this value is for the number of
legs of this cat and this value is for the can hunt other animals instance variable A-okay which we
actually passed the true value.
And here in line 52 we are actually trying to output these values to the screen by calling this to a
string Mefford which we actually overnighted inside this cat class as you can see here.
We actually overgraded this to a string Meffert in order to create a human readable description of DS
for instance variables and then outputs of those values to the screen here.
As you can see here chat's 1:59 a string.
So now let's actually run our project and see what happens.
So as you can see here now these values are outputted to the screen.
OK.
The name of our cat is my cat the color of our cat is white.
The speed of our cat is 40.
The power of our cat is 50.
Number of legs of our cat is four.
And our cat can fight.
OK a fight.
True.
OK.
This means that our cat can fight.
OK.
So as you can see here now you can understand the power of inheritance in Java as you can see here inside
it cat class.
We deleted all of those duplicated codes that were inside this Chad class.
OK.
We just actually inheriting all of those features and behaviors that are inside this Animal class.
OK.
So we didn't need to actually redeclare the variables and the methods that were created inside this
Animal class inside this Animal class we actually created this instance variables for example the name
of our animal the color of our animal the amount of speed of our animal and the amount of power of our
animal.
And as you can see we created a constructor here and we actually initialized these instance variables
here and we also created some getters and setters for these instance rally abettors and we we even created
a shoestring team effort here.
OK.
At inciters twittering Meffert as you can see here we actually put our own codes in order to output
these values to the screen.
So inside this math class we actually put some duplicated codes here.
We didn't need to actually implement some of these codes here.
So now I want to show you how we can actually again use the power of inheritance in order to actually
write less courts OK and write more maintainable codes.
OK.
So now I want to show you how you can actually delete those duplicated codes and write less codes and
write more maintainable codes.
OK everyone.
Now let's actually delete these lines of code here because I want to show you how you can actually use
the power of inheritance in your codes.
So as you can see here inside this animal class we have this line of code here that is completely useful
for our cat class.
OK.
This method actually outputs are the name of an object the color of an object the amount of speed of
our object and also it outputs the amount of power of our object.
OK.
So here inside this math class in order to use the implementations that are in sight these are two string
Mefford that is overrated inside these animal class.
Inside this cat class inside these two string Meffert I can just type in return super.
So remember this super refers to the superclass.
So what is the superclass the superclass of this chat class is Animal class.
OK.
Return super dot to a string so as you can see here now we did manage to successfully refer to the codes
that are inside these is Meffert inside this animal class.
OK.
So superior first to this animal class that was three in the first two this method and then it's going
to actually execute these lines of code here inside these two a string Meffert.
OK.
So inside this cathe class we actually typed in here return super's that was Thring.
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 cats color white speed 40 powerful 80.
So inside this main activity that java file here as you can see are actually specified some values for
this cat object.
And here as you can see in this emulator as you can see the name of my child is my cats the color of
my cat is white and this is the value for my speed.
And this is the value for the power of my cat.
And we also actually specified two other values for my cat object which we can't actually see in the
emulator how we can actually output these values to the screen.
So and so it is Chatz class as you can see here.
We did manage to actually use implementations that are inside the twisting Meffert inside this Animal
class in our chat class.
OK.
By just typing super THAT WAS think OK.
Superiorly first the superclass which is the Animal class that was three in the first two that westering
Meffert that is inside the Animal class.
OK.
And here we actually used it.
These are capabilities that are inside this Animal class but inside is Kathe class.
We've got two other instance variables that are specific only to this class Class.
OK.
So in order to actually output these values to the screen here I can just put in a plus operator here.
And then I can just type in strange dot format.
And here first of all I can actually specify the formatting instructions here present as Colan percent
the space per cent as Colan per cent B.
And then I can actually specify the arguments.
So for the first Torchin I need to actually specify I need to actually putting out an argument of types
3.
So I just put in a string literal here inside these double quotes.
I can just type in number of legs.
OK.
And for this person D I need to actually specify an argument of type integer.
OK.
Number of legs.
And then again I need to actually specify an argument of type string here.
So as you can see here this percent as talken needs an argument of type string.
So I just put in two double quotes here.
So here I want to actually use a string literal again fight colon and then I refer to the name of my
instance variable as you can see can hunt other animals.
OK.
So as you can see here we've got this person's behere and this token is for values of type Boolean.
OK Chad hunt other animals so let's actually run our project and see what happens.
So as you can see here now these values are out here a number of legs for fight true so we can actually
put a space between these two values.
Number 30 and this number of legs a string literal here.
So inside this animal class here I can actually put a space after this person D here and if I don't
my project again.
Now we can't see a space between these two values.
OK.
Number fretty our space.
Number of legs.
OK.
So what's going on here.
What did they do to actually come out with these values to the screen in this math class.
As you can see first of all I actually used the implementations that are inside the superclass of these
chat class.
OK so the superclass of this class class is animal.
OK.
I actually use the implementations that are inside the three inch Meffert that is inside these Animal
class.
OK.
The superclass of this class is Animal class.
OK.
So here we actually use the implementations of that Smurfette inside the superclass.
And here we actually use this D-plus operator in order to concatenate these two string values here.
OK.
So this piece of code here actually returns a value of type strange.
OK so we can actually say that this piece of code is our streambed value.
OK.
And here we actually put a plus operator here in order to concatenate this value with another string
value.
OK.
So again this string value here provides us with another string value.
Ok 3 in that format as you can see here first we actually specified the formatting instructions of this
method and then we actually put some arguments that are related to these tokens.
OK.
Number of legs and can hunt other animals.