1 00:00:00,650 --> 00:00:06,040 Biton is one object oriented programming language, so it supports inheritance. 2 00:00:06,400 --> 00:00:11,200 So this video will be we'll be discussing what is spight on inheritance. 3 00:00:12,350 --> 00:00:19,340 So it refers to defining a new class with little or no modification to an existing class. 4 00:00:19,580 --> 00:00:23,600 So a new class will get created from the existing class with the will. 5 00:00:23,900 --> 00:00:27,740 Some changes are may not be having any change at all. 6 00:00:28,100 --> 00:00:31,700 The new class is called a derived class, also known as the child class. 7 00:00:32,060 --> 00:00:38,330 And the class from which one of the classes from which it inherits will be known as a best class or 8 00:00:38,330 --> 00:00:39,260 dependent class. 9 00:00:39,710 --> 00:00:40,910 So just consider this one. 10 00:00:40,920 --> 00:00:43,370 We're having multiple different types of inheritances. 11 00:00:43,550 --> 00:00:45,230 How many types of inheritance are there? 12 00:00:45,530 --> 00:00:46,430 So five types up. 13 00:00:46,640 --> 00:00:47,510 What is the first one? 14 00:00:47,840 --> 00:00:49,130 There is a single inheritance. 15 00:00:49,400 --> 00:00:50,060 Means what? 16 00:00:50,390 --> 00:00:53,320 Means one best class and one D-Day plus. 17 00:00:53,390 --> 00:00:55,370 So that is known as a single inheritance. 18 00:00:55,820 --> 00:00:57,980 So here you are having the multiple inheritance. 19 00:00:58,010 --> 00:00:58,970 What does it mean? 20 00:00:59,240 --> 00:01:03,110 We'll be having my best classes not only to we can have more than two. 21 00:01:03,120 --> 00:01:07,370 Also, we'll be having multiple best classes, but one direct class. 22 00:01:07,670 --> 00:01:12,050 So this particular data class, we inherit the properties from all the best classes. 23 00:01:12,620 --> 00:01:14,450 This is our hierarchical inheritance. 24 00:01:14,510 --> 00:01:18,370 Only one best class and multiple derived classes here. 25 00:01:18,370 --> 00:01:20,060 I've shown three direct classes. 26 00:01:20,300 --> 00:01:21,290 It may be two also. 27 00:01:21,290 --> 00:01:22,970 It may be five or six, maybe seven. 28 00:01:22,970 --> 00:01:24,320 Also here, do it. 29 00:01:24,350 --> 00:01:29,990 Having the Mitel level inheritance, what is the meaning of this multilevel inheritance? 30 00:01:30,440 --> 00:01:31,760 So this is the best class. 31 00:01:32,110 --> 00:01:38,100 This is a direct class and for the C being the best class and sees the direct class here. 32 00:01:38,490 --> 00:01:41,630 Well, having this hybrid inheritance, what does it mean? 33 00:01:41,660 --> 00:01:44,060 What is the meaning of this hybrid inheritance? 34 00:01:44,420 --> 00:01:46,460 So here to see this is a one best class. 35 00:01:47,060 --> 00:01:48,570 These are the Deneb classes. 36 00:01:48,860 --> 00:01:50,320 And now for this deal. 37 00:01:50,950 --> 00:01:53,570 This B C are the best classes. 38 00:01:53,690 --> 00:01:55,430 And this is the direct class. 39 00:01:55,670 --> 00:01:59,460 So that is known as that is known as Heidbrink inheritance. 40 00:01:59,480 --> 00:02:02,510 So it is actually nothing, but it is hierarchical. 41 00:02:02,920 --> 00:02:04,640 My DBL inheritance. 42 00:02:04,830 --> 00:02:07,370 It is hierarchical, mountable inheritance. 43 00:02:07,670 --> 00:02:13,640 In this way, you also can have a combination that is that is of a multiple and hierarchical inheritance. 44 00:02:13,880 --> 00:02:16,160 So for multiple best classes, one did a plus. 45 00:02:16,530 --> 00:02:19,610 And from one best class to the makeable derived classes. 46 00:02:19,670 --> 00:02:20,930 So that can also happen. 47 00:02:21,260 --> 00:02:24,200 That is known as mountable hierarchical inheritance. 48 00:02:24,770 --> 00:02:28,370 So here to discuss what are the different types of inheritance is out there. 49 00:02:28,610 --> 00:02:33,880 So let us go for one practical demonstration for the better understanding in decision. 50 00:02:33,920 --> 00:02:40,700 We shall discuss inheritance and polymorphism, which will be observed in Biton in object oriented programming 51 00:02:41,300 --> 00:02:42,920 here to define one class. 52 00:02:43,070 --> 00:02:44,650 So here you have defined one class. 53 00:02:44,660 --> 00:02:46,160 The name of the class is my board. 54 00:02:46,770 --> 00:02:47,780 This is the constructor. 55 00:02:48,260 --> 00:02:49,190 These are what type? 56 00:02:49,250 --> 00:02:52,250 That is one method and can stream is out of the method. 57 00:02:52,670 --> 00:02:53,050 The method. 58 00:02:53,060 --> 00:02:54,260 What is a very simple verb. 59 00:02:54,320 --> 00:03:01,280 Just put one print statement here and here we are having another class that is known as my pinguin who 60 00:03:01,280 --> 00:03:05,930 just inheriting my board see my but my wardrobe defined here. 61 00:03:05,960 --> 00:03:07,060 So it makes a good code. 62 00:03:07,460 --> 00:03:12,410 So here the class has been defined and my pinguin is inheriting my board. 63 00:03:13,190 --> 00:03:16,820 So like about Java here, we need to write extents or any other key. 64 00:03:17,720 --> 00:03:22,610 Just within this bracket were mentioning the respective class name, the class name, which will be 65 00:03:22,610 --> 00:03:27,260 mentioned within this bracket, will be known as a best class, also known as the superclass. 66 00:03:27,620 --> 00:03:30,050 And this is our direct class or subclass here. 67 00:03:30,500 --> 00:03:35,900 So in case of Biton, the class inheritance will be written using this particular syntax. 68 00:03:36,590 --> 00:03:40,230 So this might be in Gwinn is having the respective constructed. 69 00:03:40,730 --> 00:03:42,830 And here you are calling the best class constructor. 70 00:03:42,860 --> 00:03:45,350 So this class will be called by this part of me thought. 71 00:03:45,750 --> 00:03:50,300 And it's constructed is all is underscored, underscore in it, underscore, underscore method. 72 00:03:50,870 --> 00:03:52,900 So that is a best class constructor directly. 73 00:03:53,120 --> 00:03:55,070 And then one statement to get printed. 74 00:03:55,640 --> 00:03:56,960 And who is this. 75 00:03:57,170 --> 00:03:58,700 And can can run. 76 00:03:58,730 --> 00:04:02,120 So these are the other two methods in this might be in Greenglass. 77 00:04:02,600 --> 00:04:07,920 So just remember in my board, along with the constructor, we are having what type and can swim. 78 00:04:08,470 --> 00:04:15,350 And in case up my pinguin we're having this constructor and along it we are having who is this and can 79 00:04:15,350 --> 00:04:15,710 run. 80 00:04:15,910 --> 00:04:20,180 So these two other methods that they're defining, one pinguin plus object. 81 00:04:20,270 --> 00:04:22,310 So it has been defined in a very simple way. 82 00:04:22,700 --> 00:04:27,230 So that means we're having this might pinguin and then we're having the PDU. 83 00:04:27,230 --> 00:04:28,360 One is the object name. 84 00:04:29,060 --> 00:04:30,210 So we do one dot. 85 00:04:30,290 --> 00:04:31,040 What type? 86 00:04:31,160 --> 00:04:34,070 This particular what date was defined in the class. 87 00:04:34,100 --> 00:04:42,980 That is a my Baade as my bard has got inherited into my pinguin so my baat mehtar can be accessed from 88 00:04:42,980 --> 00:04:44,540 this might pinguin object. 89 00:04:44,930 --> 00:04:48,530 So that's why you want what type can be executed. 90 00:04:49,010 --> 00:04:50,460 But having BGT one dot. 91 00:04:50,660 --> 00:04:51,740 Having B.G. one dot. 92 00:04:52,070 --> 00:04:53,150 Who is this. 93 00:04:53,210 --> 00:04:54,140 So it is defined. 94 00:04:54,200 --> 00:04:57,210 In case of my pinguin you can easily find in mind being green. 95 00:04:57,500 --> 00:04:58,640 Who is this is defined. 96 00:04:59,150 --> 00:05:04,150 But having this p.g one dot can stream it had been B.G. wondered can run. 97 00:05:04,480 --> 00:05:05,460 B.G. wondered can seem. 98 00:05:05,750 --> 00:05:09,110 Was defined in my class and B.G. one dot can run. 99 00:05:09,410 --> 00:05:10,380 This kind can run. 100 00:05:10,460 --> 00:05:11,530 Was defined in my. 101 00:05:11,780 --> 00:05:14,520 And that is what type and can seem. 102 00:05:14,950 --> 00:05:17,680 We are inheriting Web, we're getting this one from the best class. 103 00:05:17,740 --> 00:05:20,590 That is my bird because there they are defined. 104 00:05:22,070 --> 00:05:23,720 So now let me go for the execution. 105 00:05:24,260 --> 00:05:29,300 My bodyguard class constructed is executing, my penguin class constructed is executing. 106 00:05:29,330 --> 00:05:32,910 You can easily find that here you call the best class constructor. 107 00:05:32,960 --> 00:05:34,940 So that's why the condor has gone to this. 108 00:05:35,300 --> 00:05:41,690 So my world class constructor is executing has got printed at first, then my being green class constructor 109 00:05:41,810 --> 00:05:42,530 is executing. 110 00:05:42,530 --> 00:05:44,680 So that string has got printed. 111 00:05:45,140 --> 00:05:46,760 So now it called what type. 112 00:05:46,940 --> 00:05:49,300 So what type is having the string. 113 00:05:49,310 --> 00:05:50,420 That is I am about. 114 00:05:50,570 --> 00:05:51,920 So that has to be printed. 115 00:05:52,700 --> 00:05:53,720 That has got printed. 116 00:05:54,170 --> 00:05:54,980 I'm pinguin. 117 00:05:55,040 --> 00:05:57,860 So now next method we call this is who is this. 118 00:05:58,220 --> 00:05:59,290 So I am pinguin. 119 00:05:59,330 --> 00:06:00,990 So that string has got printed. 120 00:06:01,460 --> 00:06:03,440 Next week when for this can swim. 121 00:06:03,790 --> 00:06:06,270 So against whom is having this string to be printed. 122 00:06:06,320 --> 00:06:07,430 That is I can swim. 123 00:06:07,730 --> 00:06:09,230 So I can swim has got printed. 124 00:06:09,500 --> 00:06:12,530 Now we are having this can run and I can run faster. 125 00:06:13,040 --> 00:06:15,710 So in this way this particular string has got printed. 126 00:06:16,130 --> 00:06:21,860 So using this example, we have shown you how inheritance can be implemented in Python. 127 00:06:22,580 --> 00:06:24,410 So let us go for another example here. 128 00:06:25,010 --> 00:06:27,500 Having one class, the name of the class is Mike Barratt. 129 00:06:28,040 --> 00:06:29,000 And here we are having. 130 00:06:29,020 --> 00:06:30,860 Can fly and can swim. 131 00:06:31,400 --> 00:06:34,190 So obviously Batard can fly so bad it can fly. 132 00:06:34,240 --> 00:06:36,100 But Batard cannot seem so bad. 133 00:06:36,100 --> 00:06:37,070 It can't swim. 134 00:06:37,460 --> 00:06:38,380 I'm having another class. 135 00:06:38,450 --> 00:06:39,680 That is my penguin. 136 00:06:39,900 --> 00:06:40,990 We just having two methods. 137 00:06:41,000 --> 00:06:41,880 The same simple. 138 00:06:41,900 --> 00:06:47,770 But I can easily find that can fly self and def can swim self. 139 00:06:47,810 --> 00:06:51,190 So you see we're having the same property defined here also. 140 00:06:51,830 --> 00:06:52,740 OK Narcy. 141 00:06:53,330 --> 00:06:57,050 So def can fly self so penguin cannot fly. 142 00:06:57,410 --> 00:07:00,770 And Dave can see himself where having penguins can swim. 143 00:07:01,520 --> 00:07:05,420 So now we are having one common interface that is flying bird DST. 144 00:07:05,760 --> 00:07:09,260 OK, so I'm going for this bird dog can fly. 145 00:07:09,380 --> 00:07:11,450 And also Bartok can swim. 146 00:07:12,760 --> 00:07:18,940 So, Ed, in this particular method, we were just passing this board as input palmitate and we're calling 147 00:07:18,940 --> 00:07:21,750 this Bardock can fly and Baudot can see. 148 00:07:22,360 --> 00:07:28,510 So here we have defined one Petrak class object, my pilot class object and one my Pinguin class object. 149 00:07:29,020 --> 00:07:31,450 So we're calling this flying part test. 150 00:07:31,480 --> 00:07:36,220 We're calling this flying part test with this baat parrot, that is which is a paddock class object 151 00:07:36,640 --> 00:07:39,220 and bought Penguin, which is the penguin class object. 152 00:07:39,730 --> 00:07:42,520 So what did happen when we were passing this back? 153 00:07:42,910 --> 00:07:43,410 Parrot. 154 00:07:43,720 --> 00:07:45,370 So that is a parrot class object. 155 00:07:45,760 --> 00:07:51,070 So that parrot class object can fly and parrot class object that can swim, you get executed. 156 00:07:51,430 --> 00:07:58,170 So as it is allowed that this can fly and this can swim, the respective body will get executed and 157 00:07:58,190 --> 00:08:00,000 respective strings are going to get printed. 158 00:08:00,700 --> 00:08:05,770 But when you were passing this board Penguin, which is the mine penguin class object as input parameter 159 00:08:05,770 --> 00:08:07,270 to this flying bar test. 160 00:08:07,720 --> 00:08:13,800 So in that case, this board can fly and board can swim, will be operated on, this being my pinguin 161 00:08:13,830 --> 00:08:14,650 class objects. 162 00:08:15,040 --> 00:08:18,250 So in that case, what will happen will be getting this penguin cannot fly. 163 00:08:18,310 --> 00:08:20,970 And Penguin can swim in gives off flying. 164 00:08:20,980 --> 00:08:23,850 But this barred penguin I think is flying. 165 00:08:23,900 --> 00:08:26,230 But desde back parrot would have been better. 166 00:08:26,240 --> 00:08:28,400 Can fly and parrot cannot seem. 167 00:08:28,900 --> 00:08:35,320 So you can find that how these classes are having their respective objects and objects are being passed 168 00:08:35,320 --> 00:08:41,920 to this flying bar test and respectively their respective can fly and can see method will get executed. 169 00:08:42,460 --> 00:08:48,520 So in this particular session we have discussed what is the how to implement the inheritance, how to 170 00:08:48,520 --> 00:08:50,970 do the polymorphism in about Python. 171 00:08:51,110 --> 00:08:51,550 You know what? 172 00:08:51,610 --> 00:08:52,960 Object oriented programming. 173 00:08:53,560 --> 00:08:54,750 Thanks for watching this video.