Abstraction in Kotlin - OOP in Kotlin

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
So, hey everyone I Vishaal welcome you to the new video of Neat Roots. In this video, we are going to study about the fourth and last pillar of Object Oriented Programming named Extraction, so let's start in today's video. Welcome, new era of Android app development and now We will become "ANDROID KAY CHAMPION" so first of all, let us see now what is the meaning of Kshetra, so now if we talk about Kshetra in simple, what does it mean, it means that brother, do not take the mango, its symbol means the same. Is the extraction of IT mains inside programming ? This is to say that brother, if it is a thing of your importance, then you do not care what is going on behind it, it means that the additional details are hidden from the user, so this is the right. There is also the meaning of series, so let's now see it by coding it in programming. If it is a part of an object, then it will obviously come within object orientation programming. We will create a function which will be Hello, it is a function of extract type. Okay, and this is the class here. Don't you know that once before we had created a class with the name A, hence the issue is A, so we will make it A1 here, it is ok and it is saying that this is one, make it abstract too, what does it mean, what is the relief, look at the abstract function. Is it to speak or abstract class? It speaks both means kid off with each other that if any function is abstract inside a class then that class should also be abstract. Right and one more very important thing that has come. It has come that if any class is abstract then at least it should have a function. It should have one function. Okay, so this is a very important thing, so what will we do, we will name it abstract. Okay, so you don't have any problem with it, but if I If I remove it from here then I will get an error that it should have a function which is fine or there should be a function body inside it but if I extract it then it will not give me any problem. Now let's create another function here. Which is that they will give their body inside hello tu and hello tu, which will print their function in it, hello this is hello from hello, so what is a function class, you have understood that such classes have minimum one function . Function should be absent. G is a part of class, that is to say that class should be attractive. These two things fit with each other, then you can understand it in this way. Now I will talk about it here and here I will talk about its function . I will make it in the fan and here I have started telling you a very important thing, that is, you cannot create any variable directly in an abstract class, that means diet cannot create any object, I will tell you by doing it here, we do that also and Here, if I do A1 tomorrow, neither is it nor mine, it will give a note to me here, create instance of class, so this is a very different thing with absent class, okay, you are not any object of affected class. If you can create one, then what you have to do for this is that you have to inherit the abstract class from some base class and there you have to keep in mind that your attract function which you have abstracted here should be called a function. Then you have to give its body in its child class or in its class. In the G class, you have inherited it and if you do not do this, then the inherited class is directly automatically accepted. Okay, so let's come here. And here we create a class called class b tu or b one because our b1 has already been created so it is okay and here what we will do is get it extended, by extend I mean get it hit so that it is okay with A1 so here But A1, this will be done, okay, now what was being done here, further if you see, first of all, round pastes will be applied here and give here what is being done here is that implement method or implement members and this thing you have used very much . It would be good to know that there is a special feature inside Android which is that when you inherit a class inside Android, you get to see this implemented members , so if you go to your implemented members, then you will be told to implement the Holo function, which is this. If it is a function, then the thing is that you are adopting the G class, it is an abstract class, so if you are adopting the absolute class, then you have to implement its function yourself and it will be an override function, meaning. Polymorphism will also come here, why will it come because this function is already defined here, now give the body of your function here. Okay, so here we come, let's give our body of the function, so here we will give hello from abstract function, whose object will we create of b2? Okay, so here we are sorry, let's create our own object of b1 and with the object of b1, if you see the object. So you will get both the functions, Hello one and Hello, why will you get that, I told you, okay, and if you do this, then write it as if it is not yours, okay, then there are two things here, either more action is being done. So either implement it here using its method or make it also accepted, then this thing happens. Okay, so I control you and return this hello function of mine, so you can see here that here I have Okay, first of all , I can do this hello tu also tomorrow, so if I do abs dot hello tu here, then I can do hello tu also tomorrow, so now I can run this file because once I had run this file. I can run it directly, so you see this is hello from hello tu function, so here are both the functions, I am doing them tomorrow, so let me talk about the benefit of the exact class, what is the relief, then the seriousness of the abstract class is that Inside the abstract class, you can define all the methods which are required to be implemented. In which we talk about recycle , so you will see inside the recycle bin because there are three functions whenever you extend with silo, three functions are always there. We have to define one of our own, one is get count, one is on windmill holder and one is another function, write on create, okay on create is also a function, so those three functions are defined here. Why do you have to implement it? Why do you have to do it because they are already absent? Okay, one more thing you should keep in mind that when you define an abstract function inside an abstract class, here you cannot give its body, you can only You will define it, you will define its name, so every way they only define its body and then give its definition. Now if we talk about you, you have not done one thing here, you must have seen it here, I have not written open here. Why is it not written that write open even if the fish has no sense here because the class which is attracted is fixed that this class is not to be extended further so there is no need to put open here and neither have I used abstract. Why didn't you put open in front of the function because this is also expected, so it has also been implemented in the future, which means its implementation will be found in the classes that inherit it, so that is why there is no sense in it, whether to put it or not, then it is okay. This is the D region, why didn't you put the one that is open here? So I hope you have understood what a region is and you will also know how much importance the region has, especially when you inherit your classes. It is done and some functions have to be implemented in such a way, so how does it happen? You are making such an application that if a particular object enters a class, then there are some necessary things which have to be implemented here. So those functions come, you can do proton, so I hope you have now understood what is the field, so in the next video we will talk about some more advanced topics, so let's meet in the next video.
Info
Channel: Neat Roots
Views: 1,713
Rating: undefined out of 5
Keywords: kotlin video lecture hindi, kotlin tutorial series hindi, kotlin programming hindi tutorial
Id: wulwEBFwfpk
Channel Id: undefined
Length: 8min 15sec (495 seconds)
Published: Thu Mar 23 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.