Hi this is really at the heart.
Once again welcome to the next beauty of object oriented programming.
In case of Cartland.
Now in this video we will learn about Vaughters inheritance is all about.
But before that let us first understand the properties of the class in case of Codlin.
Now Bideford all the classes in Cartland are public in nature.
And also they are final in nature.
That is Bideford.
You cannot inherit from a particular class to derived class or their suppliers.
So for that the Gore-Clinton provides a special keyword of open keyword to inherit all the properties
of a particular because you have to use the keyboard of open and now for those who are beginners who
don't know what is inheritance.
Please continue with this video.
And for those who know what is inheritance quite well you may skip this review and continue watching
the next video which is there the movie deal.
So let us proceed and check out what is actually inheritance.
In case of Cartland.
So suppose I have here.
Class of dog.
And here I have a class of cat.
Now in case of Class Dog I have some properties such as Gelert breed and some methods such as Bodek
and eat.
Now similarly here in case of glass scared I have the properties of color and age and also some metrics
of meat and eat.
If you compare boot class dog and A-class scared you will find there are some common properties such
as here.
I have color here.
I have color too.
Here I have a function.
And here I have function.
So there is obviously some court repetition in both the classes.
So can we optimize both these classes.
Yes we can with the help of inheritance.
We can simply create a class of animal from which the class carrot and class dog will inherit all the
properties.
So inside the class animal vort will have is I really clear the property of color and also a method
of it.
Now this color and this method is actually present inside the dark plus and also inside the green glass.
So with the help of inheritance we can simply inherit all the properties of animals plus into dog class
and also scared.
So Inglesa Plus dog I will simply modify my code and inherit all the properties from the Animal class
like this class dog clone animal.
Now this is the syntax to inherit all the properties from the class of animal in case of Cartland galloon
followed by animal.
And this is their default primary constructor discoid.
Right.
And in case of it as well we can again use the concept of inheritance galloon space animal.
Right.
And if you notice in case of cat and dog we have simply removed the properties of color and eat function
and now we are only left with the age and myu and here breed and but just because these two properties
are actually present in case of animal that these two pluses are getting indirectly.
So this concept in case of cartilage is known as inheritance.
Right.
And now proceeding forward the classic dog and Glasscock is actually known as the subclass the child
class or their derived class.
Similarly this animal class and this animal class is actually known as the superclass base class or
building blocks.
Right like this and over all we have this animal class which is actually known as the superclass base
class or the parent class right now.
And middle class Bideford inherit from a class of any.
Now this is actually the name of the class that contains few functions.
So in Gotland always remembered every class you would define inside your project has a superclass of
any and this any contains few functions that direct talk about it shortly and now proceeding forward
let us know check out the type of inheritance supported in case of Cartland.
So their type of inheritance is same as the art of Java we have the single inheritance my deliberate
inheritance and also hierarchial inheritance.
So in case of single inheritance.
Suppose I have class B that simply inherits from class.
And in case of midlevel inheritance I have multi-level inheritance such as class C inherits from class
B inherits from class B like this.
Now in case of hierarchial inheritance I have some structure that appears to be like this.
Class B and class the inheritance from plasty and this is the same example that we saw in the previous
slide of dog Gackt an animal and not at the top.
In each of the case we have plasty Plus a and class.
So all these Blassie actually inherit from the any class are the end.
But I so always remember in case of Cartland we have a superclass of any dog.
And now this class B see and here this class B and class C are actually known as their derived class
and this class C which is present here is actually known as the superclass.
Always remember this and now in case my level inheritance we have this Glasby present in between the
class A and class seat.
So for this class C this B is actually acting as a superclass.
But for this class B This B is actually acting as a plus or the child class always remember this again.
Now Varda work class C here we have class B and class A as a superclass for this class C.
So indirectly we are getting all the properties of class B and class C inside plus the.
Because we are having here to make the level inheritance.
So the class present are at the bottom will get all the properties of the classes present ever Big such
as Class B and class C as well.
And along with class any Bideford now word this class and it stands for.
Now this class ne simply contains some before it functions such as equals method hash called mattered
to string method.
Now these methods simply return some value which is boolean in nature.
Integer and string respectively.
And what are the usage of these methods.
We talk about that shortly in our day more video but before that let us define our inheritance in case
of Cartland.
So in case of Gharlane we can define inheritance as it is a mechanism in which an object class acquires
all the properties from experience class.
Right now what does the purpose of inheritance.
So the inheritance simply increases the called re-usability which we saw in this video and it also promotes
dumbwaiter overriding functionality.
Now we have not seen varnas method or writing.
In case of Cartland So we will check it out shortly.