Heidi this is really hard.
Once again welcome to the next video.
All this object oriented programming now in this video will we talk about Vawter abstract classes methods
and also properties in case of Cartland.
So the classes in case of Cartland can also be abstract in nature.
Now what do we exactly mean by abstract.
We will check it out shortly.
Now the classes in case of Cartland can be abstract in nature.
Now before going for Vardis abstraction in Gears of Codlin.
First let me show you vort abstract classes methods and properties inside the intelligence ID street.
And then after we will discuss all the properties of these classes and methods.
So here are the intelligent ID.
I have a class of person and class Indian.
Now suppose I wanted to inherit all the properties of this class person.
So I will simply make this class person as open as simple as that.
This is the basic rule of the inheritance in case of Cartland.
Now this function becomes a part of this Indian class.
Right so this function go to school is actually is just a normal function that by default public and
final mortified attached to it.
So as we all know the functions are by default public and final in nature.
So here is the command line for this.
And now suppose inside the class of person I define one more function such as function grd the height
of the person.
Now this function is exactly the same as this function.
Both are public and final in nature by default.
Now if you wanted to override this function of get hide inside the class of Indian such as legacy override
function Guert height then the compiler will not be happy because we have to make this function as open
because by default it is final in nature.
So after we make it open we can now easily override the methods inside the subclass or other derived
class.
Now here this Indian is actually the subclass are there derived class as we all know from the previous
videos of concept of inheritance.
Now notice here these methods are actually having the blank body like this.
It is totally blank.
So that is where the curly brackets are open and closed like this here as well it is blank.
Right so this was a the open method and this was about this was about the final method.
And now let us experiment more and let us define one more function of let's see function.
Eat.
Now this time again.
Define a blank Bartie.
So this function.
It is similar to this function.
Go to school which is again final and public by default.
Right now I suppose if I append here let's see or even so this function it can now be overridden inside
the class of Indian let's say override function.
It simply override this method and you can define your own custom code inside this method right here.
And now suppose if I change this open to let's see abstract.
So what will happen now.
Bideford all the abstract matters are actually open in nature.
So you don't have to specify the open keyword explicitly.
So let us remove it.
So this is the abstract method.
Now when we declare any abstract methods or a class or a property then that abstract declaration contains
a body.
So here this method is actually having a blank body.
This is the blank.
This is the body of the matter.
Right.
So when we declare something as abstract then that declaration should not contain any body.
So these records should not exist.
So let us delete it.
So right now here is the difference between a normal function open function and an abstract function.
So here in case of abstract we don't have any metric body.
And again it is showing some error.
This abstract method is actually present inside the non abstract class of person.
So we deal with that shortly.
So right now this method is actually abstract in nature.
So let us define x.
So the abstract properties are actually Bideford open by nature.
Right.
So it is by default we are having the open keyword so we don't have to specify that or been keyword
again here like this.
It is written down now before rectifying this error here inside the main method.
Suppose if I create the instance of that class of person equal to let's say new person like this.
So here it does not show any error.
Now in order to rectify this error.
Suppose this method can only exist within the abstract class.
So here I would simply append the abstract keyword.
But I.
And now here again.
By default the abstract properties classes and methods are actually by default open in nature so we
don't have to specify open again because it is by default open by nature.
Right now here it shows some error can cannot create an instance of an abstract classes.
Now it is a property of an abstract class that you can not instantiate or create the objects of this
abstract class.
Right so the compiler will simply throw some exception here because this is not allowed to create any
object of the abstract class.
So here I have to remove that statement in order to rectify the error.
Right now what is the advantage of using the abstract method such as IID.
Now here inside the subclass of Indian I have simply overridden this method and also get height Metford
this get height method is actually open in nature and this method is actually abstract as well as open
in nature.
That is very we very true do what I did here.
Now suppose if I delete this get method from here then the compiler is still happy.
It does not show any error because this open function get height is optional.
We can or we cannot override that.
Inside the Indian class it is totally up to our choice but if we remove this abstract method of it let
us remove it.
Then here the compiler is not happy.
It simply says that this Indian class should override all the abstract methods and properties present
inside the superclass of person which is again abstract in nature.
Right.
So if you define any abstract keyword in the superclass of person so you need to override this method
inside the class of Indian which is a plus.
So here to rectify this error I will simply press please enter and simply implement the members and
simply select this method.
And here we go.
The intelligent ID as has simply done the job for us.
Here we have over a function.
And here this is there are two implementation.
And now if you aren't you can optionally override this get method because it is only open not abstract.
And now what about the field variables.
Suppose if I create here that lets the name of that type of string write equal to.
Let's see dummy underscore name.
This is my domain name right.
Now suppose if I want to override this property inside the class of Indian so I have to make this very
well as often as we all are aware of this.
Similar to what we have done here right.
Or here for it.
So here inside the class of Indian I will simply override the variable of name order type of string.
And here let's see I will call dummy underscore Indian name right.
Something like that.
So I have simply overriding the value of name inside the subclass.
And now the default value is the Indian name.
Now suppose if I append abstract here and so we need to remove this open keyword because it is returned.
Right so here now it shows some error that the abstract variable or the property cannot be instantiated.
Now similar to method like we don't have a Metford body in case of abstract method.
Here again we can never instantiate a property that is abstract in nature.
So here we have to remove this equal to operator.
So the abstract property and abstract method are just defined.
They don't contain any code inside it.
Right so now suppose if I come in this here so the compiler is again not happy because in the superclass
of person we have an abstract variable name so whatever we define as an abstract we need to override
that complexity inside the surplus.
So if I remove this.
And now if I press on it.
And so here it simply shows implement members.
So simply click on it select the name.
They don't.
OK.
So by default the indelible ID has simply overridden the variable name which is of the type of string.
Now this is their default get that sector.
So let us remove it.
We don't need it.
And now here if you override a variable or the property then you need to define its body that is unique
to initialize it.
Let's see again dummy in your name.
So this was all about the abstract Plus person abstract property and also abstract method.
And now here let me add some command line.
You can not create the instance of the abstract class for your better understanding.
So at last later seek out the properties of the abstract class methods and also property.
Right.
So here the rule of abstract class is to just provide a set of methods and properties that is the abstract
class is just off the placeholder to use it just prove why it's the set of mentors and properties without
any value or without any body.
So the abstract class are actually partially defined class.
It is a class but it is partially defined right.
It does not contain.
It's all good.
And next we have abstract matters which have nobody even declared.
Right.
And also we have abstract properties that cannot be initialized then declared.
So previously we had this abstract matter that contains nobody.
Again we have abstract property that contains no value.
So are the N word.
We can include from this value.
So at the end we conclude that we cannot create the instance or the object of the abstract class.
But I and we always need to override the abstract methods properties inside their derived class or supplies.
Otherwise the compiler is sure some error.
This is a basic rule of abstraction in case of Cartland.
So this was all about this video.
Hope you like 40 or so and see you guys in the next video.
Thanks for watching.
Have a good day.