1 00:00:00,370 --> 00:00:01,730 Heidi this is really hard. 2 00:00:01,730 --> 00:00:03,720 Once again welcome to the next video. 3 00:00:03,720 --> 00:00:10,500 All this object oriented programming now in this video will we talk about Vawter abstract classes methods 4 00:00:10,530 --> 00:00:13,400 and also properties in case of Cartland. 5 00:00:13,560 --> 00:00:17,830 So the classes in case of Cartland can also be abstract in nature. 6 00:00:17,880 --> 00:00:20,220 Now what do we exactly mean by abstract. 7 00:00:20,220 --> 00:00:22,160 We will check it out shortly. 8 00:00:22,170 --> 00:00:25,940 Now the classes in case of Cartland can be abstract in nature. 9 00:00:25,980 --> 00:00:29,910 Now before going for Vardis abstraction in Gears of Codlin. 10 00:00:29,910 --> 00:00:37,020 First let me show you vort abstract classes methods and properties inside the intelligence ID street. 11 00:00:37,280 --> 00:00:42,400 And then after we will discuss all the properties of these classes and methods. 12 00:00:42,540 --> 00:00:44,870 So here are the intelligent ID. 13 00:00:44,880 --> 00:00:47,750 I have a class of person and class Indian. 14 00:00:47,760 --> 00:00:52,440 Now suppose I wanted to inherit all the properties of this class person. 15 00:00:53,190 --> 00:00:57,890 So I will simply make this class person as open as simple as that. 16 00:00:57,900 --> 00:01:01,900 This is the basic rule of the inheritance in case of Cartland. 17 00:01:01,930 --> 00:01:06,100 Now this function becomes a part of this Indian class. 18 00:01:06,160 --> 00:01:13,290 Right so this function go to school is actually is just a normal function that by default public and 19 00:01:13,290 --> 00:01:15,720 final mortified attached to it. 20 00:01:15,720 --> 00:01:20,340 So as we all know the functions are by default public and final in nature. 21 00:01:20,370 --> 00:01:22,600 So here is the command line for this. 22 00:01:22,950 --> 00:01:30,390 And now suppose inside the class of person I define one more function such as function grd the height 23 00:01:30,390 --> 00:01:31,620 of the person. 24 00:01:31,670 --> 00:01:35,210 Now this function is exactly the same as this function. 25 00:01:35,250 --> 00:01:38,390 Both are public and final in nature by default. 26 00:01:38,610 --> 00:01:45,600 Now if you wanted to override this function of get hide inside the class of Indian such as legacy override 27 00:01:46,660 --> 00:01:55,330 function Guert height then the compiler will not be happy because we have to make this function as open 28 00:01:56,310 --> 00:01:58,990 because by default it is final in nature. 29 00:01:59,050 --> 00:02:04,630 So after we make it open we can now easily override the methods inside the subclass or other derived 30 00:02:04,630 --> 00:02:05,400 class. 31 00:02:05,410 --> 00:02:11,080 Now here this Indian is actually the subclass are there derived class as we all know from the previous 32 00:02:11,080 --> 00:02:13,510 videos of concept of inheritance. 33 00:02:13,510 --> 00:02:18,330 Now notice here these methods are actually having the blank body like this. 34 00:02:18,340 --> 00:02:19,490 It is totally blank. 35 00:02:19,750 --> 00:02:24,660 So that is where the curly brackets are open and closed like this here as well it is blank. 36 00:02:25,170 --> 00:02:31,630 Right so this was a the open method and this was about this was about the final method. 37 00:02:31,860 --> 00:02:36,800 And now let us experiment more and let us define one more function of let's see function. 38 00:02:36,830 --> 00:02:38,420 Eat. 39 00:02:38,590 --> 00:02:39,630 Now this time again. 40 00:02:39,640 --> 00:02:41,400 Define a blank Bartie. 41 00:02:41,560 --> 00:02:42,370 So this function. 42 00:02:42,400 --> 00:02:44,140 It is similar to this function. 43 00:02:44,140 --> 00:02:47,830 Go to school which is again final and public by default. 44 00:02:47,840 --> 00:02:57,480 Right now I suppose if I append here let's see or even so this function it can now be overridden inside 45 00:02:57,480 --> 00:03:01,910 the class of Indian let's say override function. 46 00:03:02,030 --> 00:03:08,310 It simply override this method and you can define your own custom code inside this method right here. 47 00:03:09,310 --> 00:03:14,570 And now suppose if I change this open to let's see abstract. 48 00:03:14,710 --> 00:03:16,760 So what will happen now. 49 00:03:16,810 --> 00:03:20,940 Bideford all the abstract matters are actually open in nature. 50 00:03:21,100 --> 00:03:25,010 So you don't have to specify the open keyword explicitly. 51 00:03:25,330 --> 00:03:26,830 So let us remove it. 52 00:03:26,860 --> 00:03:29,230 So this is the abstract method. 53 00:03:29,260 --> 00:03:37,440 Now when we declare any abstract methods or a class or a property then that abstract declaration contains 54 00:03:37,530 --> 00:03:38,650 a body. 55 00:03:38,650 --> 00:03:43,060 So here this method is actually having a blank body. 56 00:03:43,060 --> 00:03:44,550 This is the blank. 57 00:03:44,860 --> 00:03:47,010 This is the body of the matter. 58 00:03:47,250 --> 00:03:47,790 Right. 59 00:03:48,770 --> 00:03:55,840 So when we declare something as abstract then that declaration should not contain any body. 60 00:03:56,030 --> 00:03:58,890 So these records should not exist. 61 00:03:58,910 --> 00:04:01,010 So let us delete it. 62 00:04:01,010 --> 00:04:07,530 So right now here is the difference between a normal function open function and an abstract function. 63 00:04:07,550 --> 00:04:11,370 So here in case of abstract we don't have any metric body. 64 00:04:11,660 --> 00:04:13,510 And again it is showing some error. 65 00:04:13,580 --> 00:04:18,860 This abstract method is actually present inside the non abstract class of person. 66 00:04:18,860 --> 00:04:21,250 So we deal with that shortly. 67 00:04:21,260 --> 00:04:24,870 So right now this method is actually abstract in nature. 68 00:04:24,890 --> 00:04:26,620 So let us define x. 69 00:04:26,660 --> 00:04:30,890 So the abstract properties are actually Bideford open by nature. 70 00:04:30,890 --> 00:04:31,530 Right. 71 00:04:31,580 --> 00:04:36,560 So it is by default we are having the open keyword so we don't have to specify that or been keyword 72 00:04:36,650 --> 00:04:37,940 again here like this. 73 00:04:37,940 --> 00:04:42,650 It is written down now before rectifying this error here inside the main method. 74 00:04:42,650 --> 00:04:49,400 Suppose if I create the instance of that class of person equal to let's say new person like this. 75 00:04:49,400 --> 00:04:51,650 So here it does not show any error. 76 00:04:51,860 --> 00:04:54,270 Now in order to rectify this error. 77 00:04:54,320 --> 00:04:58,640 Suppose this method can only exist within the abstract class. 78 00:04:58,670 --> 00:05:01,930 So here I would simply append the abstract keyword. 79 00:05:02,020 --> 00:05:02,630 But I. 80 00:05:02,780 --> 00:05:03,750 And now here again. 81 00:05:03,810 --> 00:05:10,460 By default the abstract properties classes and methods are actually by default open in nature so we 82 00:05:10,460 --> 00:05:15,900 don't have to specify open again because it is by default open by nature. 83 00:05:15,990 --> 00:05:22,280 Right now here it shows some error can cannot create an instance of an abstract classes. 84 00:05:22,370 --> 00:05:29,420 Now it is a property of an abstract class that you can not instantiate or create the objects of this 85 00:05:29,540 --> 00:05:30,610 abstract class. 86 00:05:30,650 --> 00:05:37,550 Right so the compiler will simply throw some exception here because this is not allowed to create any 87 00:05:37,550 --> 00:05:39,850 object of the abstract class. 88 00:05:39,890 --> 00:05:44,270 So here I have to remove that statement in order to rectify the error. 89 00:05:44,270 --> 00:05:49,960 Right now what is the advantage of using the abstract method such as IID. 90 00:05:50,060 --> 00:05:56,810 Now here inside the subclass of Indian I have simply overridden this method and also get height Metford 91 00:05:57,410 --> 00:06:04,940 this get height method is actually open in nature and this method is actually abstract as well as open 92 00:06:04,940 --> 00:06:05,930 in nature. 93 00:06:05,930 --> 00:06:09,060 That is very we very true do what I did here. 94 00:06:09,290 --> 00:06:16,940 Now suppose if I delete this get method from here then the compiler is still happy. 95 00:06:16,940 --> 00:06:22,520 It does not show any error because this open function get height is optional. 96 00:06:22,550 --> 00:06:25,060 We can or we cannot override that. 97 00:06:25,160 --> 00:06:32,300 Inside the Indian class it is totally up to our choice but if we remove this abstract method of it let 98 00:06:32,300 --> 00:06:33,590 us remove it. 99 00:06:33,740 --> 00:06:36,400 Then here the compiler is not happy. 100 00:06:36,410 --> 00:06:43,520 It simply says that this Indian class should override all the abstract methods and properties present 101 00:06:43,550 --> 00:06:47,560 inside the superclass of person which is again abstract in nature. 102 00:06:47,560 --> 00:06:48,020 Right. 103 00:06:48,290 --> 00:06:55,340 So if you define any abstract keyword in the superclass of person so you need to override this method 104 00:06:55,670 --> 00:06:59,030 inside the class of Indian which is a plus. 105 00:06:59,090 --> 00:07:06,080 So here to rectify this error I will simply press please enter and simply implement the members and 106 00:07:06,080 --> 00:07:07,920 simply select this method. 107 00:07:08,090 --> 00:07:09,370 And here we go. 108 00:07:09,440 --> 00:07:13,860 The intelligent ID as has simply done the job for us. 109 00:07:13,880 --> 00:07:16,200 Here we have over a function. 110 00:07:16,400 --> 00:07:19,120 And here this is there are two implementation. 111 00:07:19,130 --> 00:07:26,140 And now if you aren't you can optionally override this get method because it is only open not abstract. 112 00:07:26,540 --> 00:07:29,150 And now what about the field variables. 113 00:07:29,150 --> 00:07:37,670 Suppose if I create here that lets the name of that type of string write equal to. 114 00:07:37,770 --> 00:07:40,730 Let's see dummy underscore name. 115 00:07:40,770 --> 00:07:42,440 This is my domain name right. 116 00:07:42,540 --> 00:07:49,770 Now suppose if I want to override this property inside the class of Indian so I have to make this very 117 00:07:49,830 --> 00:07:53,700 well as often as we all are aware of this. 118 00:07:53,700 --> 00:07:55,850 Similar to what we have done here right. 119 00:07:55,920 --> 00:07:57,540 Or here for it. 120 00:07:57,630 --> 00:08:04,830 So here inside the class of Indian I will simply override the variable of name order type of string. 121 00:08:04,980 --> 00:08:11,680 And here let's see I will call dummy underscore Indian name right. 122 00:08:11,850 --> 00:08:12,780 Something like that. 123 00:08:12,870 --> 00:08:16,490 So I have simply overriding the value of name inside the subclass. 124 00:08:16,500 --> 00:08:20,350 And now the default value is the Indian name. 125 00:08:20,350 --> 00:08:28,570 Now suppose if I append abstract here and so we need to remove this open keyword because it is returned. 126 00:08:28,930 --> 00:08:37,720 Right so here now it shows some error that the abstract variable or the property cannot be instantiated. 127 00:08:37,740 --> 00:08:43,140 Now similar to method like we don't have a Metford body in case of abstract method. 128 00:08:43,220 --> 00:08:49,050 Here again we can never instantiate a property that is abstract in nature. 129 00:08:49,050 --> 00:08:52,170 So here we have to remove this equal to operator. 130 00:08:52,530 --> 00:08:57,390 So the abstract property and abstract method are just defined. 131 00:08:57,450 --> 00:08:59,740 They don't contain any code inside it. 132 00:08:59,890 --> 00:09:08,790 Right so now suppose if I come in this here so the compiler is again not happy because in the superclass 133 00:09:08,790 --> 00:09:16,530 of person we have an abstract variable name so whatever we define as an abstract we need to override 134 00:09:16,530 --> 00:09:19,880 that complexity inside the surplus. 135 00:09:19,890 --> 00:09:21,690 So if I remove this. 136 00:09:22,050 --> 00:09:23,900 And now if I press on it. 137 00:09:23,950 --> 00:09:27,820 And so here it simply shows implement members. 138 00:09:27,870 --> 00:09:30,280 So simply click on it select the name. 139 00:09:30,350 --> 00:09:30,710 They don't. 140 00:09:30,720 --> 00:09:31,260 OK. 141 00:09:31,320 --> 00:09:37,890 So by default the indelible ID has simply overridden the variable name which is of the type of string. 142 00:09:37,890 --> 00:09:40,450 Now this is their default get that sector. 143 00:09:40,470 --> 00:09:41,970 So let us remove it. 144 00:09:42,000 --> 00:09:43,470 We don't need it. 145 00:09:43,530 --> 00:09:50,770 And now here if you override a variable or the property then you need to define its body that is unique 146 00:09:50,830 --> 00:09:52,060 to initialize it. 147 00:09:52,320 --> 00:09:55,710 Let's see again dummy in your name. 148 00:09:55,710 --> 00:10:04,380 So this was all about the abstract Plus person abstract property and also abstract method. 149 00:10:04,440 --> 00:10:06,680 And now here let me add some command line. 150 00:10:06,690 --> 00:10:11,150 You can not create the instance of the abstract class for your better understanding. 151 00:10:11,250 --> 00:10:16,690 So at last later seek out the properties of the abstract class methods and also property. 152 00:10:16,710 --> 00:10:17,300 Right. 153 00:10:17,370 --> 00:10:25,140 So here the rule of abstract class is to just provide a set of methods and properties that is the abstract 154 00:10:25,140 --> 00:10:31,950 class is just off the placeholder to use it just prove why it's the set of mentors and properties without 155 00:10:32,010 --> 00:10:35,370 any value or without any body. 156 00:10:35,700 --> 00:10:39,880 So the abstract class are actually partially defined class. 157 00:10:39,960 --> 00:10:42,770 It is a class but it is partially defined right. 158 00:10:42,780 --> 00:10:43,870 It does not contain. 159 00:10:44,000 --> 00:10:45,120 It's all good. 160 00:10:45,210 --> 00:10:50,460 And next we have abstract matters which have nobody even declared. 161 00:10:50,460 --> 00:10:51,050 Right. 162 00:10:51,150 --> 00:10:56,220 And also we have abstract properties that cannot be initialized then declared. 163 00:10:56,250 --> 00:11:00,770 So previously we had this abstract matter that contains nobody. 164 00:11:00,810 --> 00:11:04,730 Again we have abstract property that contains no value. 165 00:11:05,040 --> 00:11:07,200 So are the N word. 166 00:11:07,200 --> 00:11:08,920 We can include from this value. 167 00:11:09,090 --> 00:11:15,760 So at the end we conclude that we cannot create the instance or the object of the abstract class. 168 00:11:15,820 --> 00:11:24,130 But I and we always need to override the abstract methods properties inside their derived class or supplies. 169 00:11:24,250 --> 00:11:27,730 Otherwise the compiler is sure some error. 170 00:11:27,770 --> 00:11:31,250 This is a basic rule of abstraction in case of Cartland. 171 00:11:31,460 --> 00:11:33,590 So this was all about this video. 172 00:11:33,590 --> 00:11:36,980 Hope you like 40 or so and see you guys in the next video. 173 00:11:36,980 --> 00:11:37,830 Thanks for watching. 174 00:11:37,850 --> 00:11:38,810 Have a good day.