1 00:00:00,620 --> 00:00:01,870 Hi this is really at the heart. 2 00:00:01,880 --> 00:00:05,560 Once again welcome to the next beauty of object oriented programming. 3 00:00:05,570 --> 00:00:07,430 In case of Cartland. 4 00:00:07,430 --> 00:00:12,440 Now in this video we will learn about Vaughters inheritance is all about. 5 00:00:12,800 --> 00:00:17,750 But before that let us first understand the properties of the class in case of Codlin. 6 00:00:17,840 --> 00:00:22,190 Now Bideford all the classes in Cartland are public in nature. 7 00:00:22,460 --> 00:00:25,200 And also they are final in nature. 8 00:00:25,430 --> 00:00:26,620 That is Bideford. 9 00:00:26,620 --> 00:00:31,650 You cannot inherit from a particular class to derived class or their suppliers. 10 00:00:31,790 --> 00:00:37,910 So for that the Gore-Clinton provides a special keyword of open keyword to inherit all the properties 11 00:00:37,910 --> 00:00:45,230 of a particular because you have to use the keyboard of open and now for those who are beginners who 12 00:00:45,230 --> 00:00:47,060 don't know what is inheritance. 13 00:00:47,060 --> 00:00:48,720 Please continue with this video. 14 00:00:48,890 --> 00:00:54,410 And for those who know what is inheritance quite well you may skip this review and continue watching 15 00:00:54,410 --> 00:00:56,780 the next video which is there the movie deal. 16 00:00:57,180 --> 00:01:00,530 So let us proceed and check out what is actually inheritance. 17 00:01:00,560 --> 00:01:02,140 In case of Cartland. 18 00:01:02,600 --> 00:01:04,570 So suppose I have here. 19 00:01:04,640 --> 00:01:06,090 Class of dog. 20 00:01:06,320 --> 00:01:08,810 And here I have a class of cat. 21 00:01:08,990 --> 00:01:16,880 Now in case of Class Dog I have some properties such as Gelert breed and some methods such as Bodek 22 00:01:16,890 --> 00:01:17,770 and eat. 23 00:01:18,110 --> 00:01:25,390 Now similarly here in case of glass scared I have the properties of color and age and also some metrics 24 00:01:25,400 --> 00:01:27,530 of meat and eat. 25 00:01:27,590 --> 00:01:34,250 If you compare boot class dog and A-class scared you will find there are some common properties such 26 00:01:34,250 --> 00:01:34,780 as here. 27 00:01:34,790 --> 00:01:36,250 I have color here. 28 00:01:36,260 --> 00:01:37,610 I have color too. 29 00:01:37,720 --> 00:01:39,290 Here I have a function. 30 00:01:39,530 --> 00:01:41,570 And here I have function. 31 00:01:42,140 --> 00:01:45,750 So there is obviously some court repetition in both the classes. 32 00:01:45,800 --> 00:01:48,660 So can we optimize both these classes. 33 00:01:48,860 --> 00:01:52,450 Yes we can with the help of inheritance. 34 00:01:52,490 --> 00:02:00,020 We can simply create a class of animal from which the class carrot and class dog will inherit all the 35 00:02:00,020 --> 00:02:01,070 properties. 36 00:02:01,340 --> 00:02:07,610 So inside the class animal vort will have is I really clear the property of color and also a method 37 00:02:07,610 --> 00:02:08,990 of it. 38 00:02:09,020 --> 00:02:16,970 Now this color and this method is actually present inside the dark plus and also inside the green glass. 39 00:02:16,970 --> 00:02:23,150 So with the help of inheritance we can simply inherit all the properties of animals plus into dog class 40 00:02:23,450 --> 00:02:25,640 and also scared. 41 00:02:25,760 --> 00:02:31,880 So Inglesa Plus dog I will simply modify my code and inherit all the properties from the Animal class 42 00:02:32,000 --> 00:02:35,120 like this class dog clone animal. 43 00:02:35,120 --> 00:02:41,750 Now this is the syntax to inherit all the properties from the class of animal in case of Cartland galloon 44 00:02:41,840 --> 00:02:43,300 followed by animal. 45 00:02:43,400 --> 00:02:46,660 And this is their default primary constructor discoid. 46 00:02:46,770 --> 00:02:47,450 Right. 47 00:02:47,720 --> 00:02:54,440 And in case of it as well we can again use the concept of inheritance galloon space animal. 48 00:02:54,450 --> 00:02:55,040 Right. 49 00:02:55,340 --> 00:03:02,270 And if you notice in case of cat and dog we have simply removed the properties of color and eat function 50 00:03:02,660 --> 00:03:09,620 and now we are only left with the age and myu and here breed and but just because these two properties 51 00:03:09,650 --> 00:03:15,340 are actually present in case of animal that these two pluses are getting indirectly. 52 00:03:15,800 --> 00:03:19,790 So this concept in case of cartilage is known as inheritance. 53 00:03:19,790 --> 00:03:20,460 Right. 54 00:03:20,840 --> 00:03:27,910 And now proceeding forward the classic dog and Glasscock is actually known as the subclass the child 55 00:03:27,920 --> 00:03:30,280 class or their derived class. 56 00:03:30,290 --> 00:03:37,400 Similarly this animal class and this animal class is actually known as the superclass base class or 57 00:03:37,450 --> 00:03:38,680 building blocks. 58 00:03:38,770 --> 00:03:46,440 Right like this and over all we have this animal class which is actually known as the superclass base 59 00:03:46,440 --> 00:03:49,340 class or the parent class right now. 60 00:03:49,620 --> 00:03:54,980 And middle class Bideford inherit from a class of any. 61 00:03:55,010 --> 00:04:00,120 Now this is actually the name of the class that contains few functions. 62 00:04:00,140 --> 00:04:06,380 So in Gotland always remembered every class you would define inside your project has a superclass of 63 00:04:06,620 --> 00:04:14,180 any and this any contains few functions that direct talk about it shortly and now proceeding forward 64 00:04:14,270 --> 00:04:18,490 let us know check out the type of inheritance supported in case of Cartland. 65 00:04:18,680 --> 00:04:24,830 So their type of inheritance is same as the art of Java we have the single inheritance my deliberate 66 00:04:24,860 --> 00:04:28,370 inheritance and also hierarchial inheritance. 67 00:04:28,580 --> 00:04:30,270 So in case of single inheritance. 68 00:04:30,320 --> 00:04:36,340 Suppose I have class B that simply inherits from class. 69 00:04:36,980 --> 00:04:45,200 And in case of midlevel inheritance I have multi-level inheritance such as class C inherits from class 70 00:04:45,230 --> 00:04:49,340 B inherits from class B like this. 71 00:04:49,340 --> 00:04:55,640 Now in case of hierarchial inheritance I have some structure that appears to be like this. 72 00:04:55,640 --> 00:05:02,150 Class B and class the inheritance from plasty and this is the same example that we saw in the previous 73 00:05:02,150 --> 00:05:06,590 slide of dog Gackt an animal and not at the top. 74 00:05:06,590 --> 00:05:11,050 In each of the case we have plasty Plus a and class. 75 00:05:11,300 --> 00:05:17,760 So all these Blassie actually inherit from the any class are the end. 76 00:05:18,120 --> 00:05:24,730 But I so always remember in case of Cartland we have a superclass of any dog. 77 00:05:24,920 --> 00:05:33,260 And now this class B see and here this class B and class C are actually known as their derived class 78 00:05:33,950 --> 00:05:38,360 and this class C which is present here is actually known as the superclass. 79 00:05:38,360 --> 00:05:45,050 Always remember this and now in case my level inheritance we have this Glasby present in between the 80 00:05:45,050 --> 00:05:46,650 class A and class seat. 81 00:05:46,880 --> 00:05:51,300 So for this class C this B is actually acting as a superclass. 82 00:05:51,440 --> 00:06:01,790 But for this class B This B is actually acting as a plus or the child class always remember this again. 83 00:06:01,940 --> 00:06:09,580 Now Varda work class C here we have class B and class A as a superclass for this class C. 84 00:06:09,860 --> 00:06:16,930 So indirectly we are getting all the properties of class B and class C inside plus the. 85 00:06:17,090 --> 00:06:19,930 Because we are having here to make the level inheritance. 86 00:06:20,000 --> 00:06:26,240 So the class present are at the bottom will get all the properties of the classes present ever Big such 87 00:06:26,240 --> 00:06:28,710 as Class B and class C as well. 88 00:06:28,880 --> 00:06:34,840 And along with class any Bideford now word this class and it stands for. 89 00:06:34,910 --> 00:06:42,380 Now this class ne simply contains some before it functions such as equals method hash called mattered 90 00:06:42,730 --> 00:06:44,270 to string method. 91 00:06:44,270 --> 00:06:48,630 Now these methods simply return some value which is boolean in nature. 92 00:06:48,770 --> 00:06:51,230 Integer and string respectively. 93 00:06:51,410 --> 00:06:53,840 And what are the usage of these methods. 94 00:06:53,940 --> 00:07:00,890 We talk about that shortly in our day more video but before that let us define our inheritance in case 95 00:07:00,890 --> 00:07:01,890 of Cartland. 96 00:07:02,150 --> 00:07:09,650 So in case of Gharlane we can define inheritance as it is a mechanism in which an object class acquires 97 00:07:09,800 --> 00:07:12,650 all the properties from experience class. 98 00:07:12,760 --> 00:07:15,640 Right now what does the purpose of inheritance. 99 00:07:15,830 --> 00:07:24,170 So the inheritance simply increases the called re-usability which we saw in this video and it also promotes 100 00:07:24,380 --> 00:07:26,580 dumbwaiter overriding functionality. 101 00:07:26,620 --> 00:07:29,470 Now we have not seen varnas method or writing. 102 00:07:29,470 --> 00:07:33,110 In case of Cartland So we will check it out shortly.