1 00:00:01,280 --> 00:00:02,360 This is getting started. 2 00:00:02,370 --> 00:00:06,710 And welcome to the next video of this object oriented programming. 3 00:00:06,810 --> 00:00:11,950 Now so far we have covered almost all topics related to the classes and objects. 4 00:00:12,060 --> 00:00:17,880 Now let us talk about the visibility modifiers in case of Cartland in case of Cartland. 5 00:00:17,970 --> 00:00:25,260 We have the visibility more defiance of public protected internal and private and now in the previous 6 00:00:25,260 --> 00:00:32,960 videos we saw that Bideford all the classes and functions are actually Bideford public in nature. 7 00:00:33,180 --> 00:00:37,000 So in Cortland everything is public in nature by default. 8 00:00:37,020 --> 00:00:38,960 Always remember this. 9 00:00:39,390 --> 00:00:44,370 So here inside the intelligent Id let us explore the visibility more. 10 00:00:44,430 --> 00:00:48,270 Now here I am working under my first daughter Katie file. 11 00:00:48,390 --> 00:00:54,570 So as our top level work classes and functions that I really define here will be by default public in 12 00:00:54,570 --> 00:00:55,320 nature. 13 00:00:55,530 --> 00:01:01,230 As for example here latest example of function trend class person. 14 00:01:01,380 --> 00:01:05,340 So Bideford this function is actually public in nature. 15 00:01:05,430 --> 00:01:05,780 Right. 16 00:01:05,850 --> 00:01:13,340 As we all know from the previous videos and now here this class is again public in nature by default. 17 00:01:13,530 --> 00:01:18,960 Now if you specify here let's see private and also private. 18 00:01:18,960 --> 00:01:25,990 Here then this method and this class person is only visible inside my first dark gate. 19 00:01:26,130 --> 00:01:34,220 Now I suppose if you create one more plus such as let's see new Gorlin file. 20 00:01:34,300 --> 00:01:39,610 See my second so here inside my second Dorte guilty. 21 00:01:39,750 --> 00:01:46,590 These two functions and classes will not be visible just because we have simply declared a private right. 22 00:01:46,710 --> 00:01:48,370 And earlier it was public. 23 00:01:48,390 --> 00:01:55,320 So these two metrics and class can be accessed inside my class Dorte guilty of us public and now in 24 00:01:55,320 --> 00:02:02,970 gardening we have one more mortified of late in doing so if you declared it internal And also this will 25 00:02:03,090 --> 00:02:08,560 as internal then this method and this class will be visible. 26 00:02:08,620 --> 00:02:13,020 Didn't see more do you know what does a Mordy will in case of Coquelin programming. 27 00:02:13,220 --> 00:02:19,040 So if you what is inside the project this Gorlin programming is actually even more D-Will so Amandi 28 00:02:19,040 --> 00:02:25,030 will in case of Cartland programming can be a bunch of Koechlin files or some other files such as a 29 00:02:25,040 --> 00:02:31,940 Mordy will can be intelligent ID Mordy will groovey more D-Will maybe in more detail and so on like 30 00:02:31,940 --> 00:02:32,440 that. 31 00:02:32,630 --> 00:02:38,960 So here if your declared internal So this function and this class will only be visible rigidness seem 32 00:02:38,960 --> 00:02:40,480 more do it right. 33 00:02:40,490 --> 00:02:47,450 So my second thought Guti will have access to this method and also this clus similar to public and now. 34 00:02:47,450 --> 00:02:55,040 Next we have at the end protected and this protected is not applicable for the high level functions 35 00:02:55,070 --> 00:02:56,120 and classes. 36 00:02:56,120 --> 00:03:02,280 So if you declare a function right inside the K-T file then this verdict is not applicable. 37 00:03:02,300 --> 00:03:03,840 So here it shows some error. 38 00:03:03,980 --> 00:03:08,090 The mortified predictor is not applicable at top level function. 39 00:03:08,100 --> 00:03:10,570 Now the same thing applies to the class as well. 40 00:03:10,580 --> 00:03:13,570 This for is not applicable here as well. 41 00:03:13,610 --> 00:03:15,920 So here let us remove it. 42 00:03:15,920 --> 00:03:18,970 And by default we are back to again public. 43 00:03:19,070 --> 00:03:25,280 Now this was all about their top level functions and classes no Valter both inside the class person. 44 00:03:25,280 --> 00:03:32,170 Suppose if I define some variables and functions and also define our derived class then what will happen. 45 00:03:32,180 --> 00:03:38,750 So here I have an open class of person which is actually acting as a superclass for this class of Indian 46 00:03:38,870 --> 00:03:39,800 right here. 47 00:03:39,890 --> 00:03:45,410 Now I suppose if I define private value equal to one inside the class of FERSEN. 48 00:03:45,560 --> 00:03:48,290 So what will happen inside the class of Indian. 49 00:03:48,380 --> 00:03:56,040 So you can not access this variable inside the class of Indian Just because this is private in nature. 50 00:03:56,240 --> 00:03:56,980 So here. 51 00:03:57,080 --> 00:04:04,350 This variable is not visible inside the class of Indian Just because we have marked it as private. 52 00:04:04,550 --> 00:04:08,930 And now let us define predicted value be equal to. 53 00:04:08,930 --> 00:04:12,840 Now here we are using the predicted keyword or the mortified. 54 00:04:12,920 --> 00:04:20,000 So this value of b is actually visible or can be accessed inside the class of Indian just because it 55 00:04:20,000 --> 00:04:21,710 is predicted in nature. 56 00:04:21,920 --> 00:04:26,610 And now next we have internal values C equal to 3. 57 00:04:26,630 --> 00:04:33,940 So since this is internal so again B along with C will be not visible inside the class of Indian. 58 00:04:34,220 --> 00:04:36,930 And now let us go in for the public. 59 00:04:36,930 --> 00:04:41,060 Val be equal to let's see then an asset. 60 00:04:41,100 --> 00:04:46,750 By default all the classes and functions and also the properties are actually public in nature. 61 00:04:46,910 --> 00:04:53,390 So here we don't have to specify this value will be as public explicitly because by default it is public 62 00:04:53,390 --> 00:04:54,140 in nature. 63 00:04:54,260 --> 00:05:02,960 So this value of the is again visible inside the class of Indian doctors we can access it here right 64 00:05:03,530 --> 00:05:03,820 now. 65 00:05:03,830 --> 00:05:08,360 Or do we mean by exactly by visibility of the functions and classes. 66 00:05:08,360 --> 00:05:10,750 Now suppose inside this class Indian. 67 00:05:10,790 --> 00:05:16,310 Suppose if I create a function of let's see test and now insert that test. 68 00:05:16,310 --> 00:05:19,020 Suppose I want to print these values. 69 00:05:19,160 --> 00:05:22,400 So here I would simply use the print function. 70 00:05:22,460 --> 00:05:24,590 Right now inside the print method. 71 00:05:24,590 --> 00:05:26,230 Suppose if I type here. 72 00:05:26,450 --> 00:05:28,850 Let's see the latest beat. 73 00:05:29,240 --> 00:05:36,010 So here the compiler will not show some error because this D can be accessed inside the class of Indian 74 00:05:36,380 --> 00:05:41,990 as it is by default probably known to destroy this value of c latest type. 75 00:05:41,990 --> 00:05:43,690 See no gain. 76 00:05:43,700 --> 00:05:49,820 C is also visible inside the class of Indian because it is internal in nature. 77 00:05:50,740 --> 00:05:55,830 And now let's just talk about this protected be ledes state B. 78 00:05:56,110 --> 00:05:58,480 And here again began to be accessed. 79 00:05:58,480 --> 00:06:06,730 Since it is declared in nature not it has come to the library value of the latest type it here but here 80 00:06:06,730 --> 00:06:10,440 the compiler is not happy because it cannot access a. 81 00:06:10,540 --> 00:06:15,410 It is invisible just because we have MMOG it private in nature. 82 00:06:15,600 --> 00:06:19,900 Right now this was about the superclass and the derived class. 83 00:06:19,990 --> 00:06:27,500 Now what about some other class where we actually define let's say remove this function best and now 84 00:06:27,500 --> 00:06:36,830 he had ordered all let us create one more class of let's see first class and now insert this last it 85 00:06:36,890 --> 00:06:38,260 started to create a method. 86 00:06:38,400 --> 00:06:39,060 Let's see. 87 00:06:39,060 --> 00:06:44,410 Pasting again to test all the visibility of these variables. 88 00:06:44,540 --> 00:06:52,940 Inside this testing method if I created the object of this person let's say value person equal to person 89 00:06:53,270 --> 00:06:56,110 right now inside their testing method that is. 90 00:06:56,130 --> 00:07:00,020 Insert the class that has nothing to do with this class of person. 91 00:07:00,110 --> 00:07:03,440 Let's see how these mortifies plays their key role. 92 00:07:03,620 --> 00:07:05,930 So here inside this let us print. 93 00:07:06,040 --> 00:07:11,200 Let's see if print flares and Dorte the. 94 00:07:11,400 --> 00:07:15,570 So here is now again visible because it is public in nature. 95 00:07:15,570 --> 00:07:17,390 Right now let us try. 96 00:07:17,670 --> 00:07:18,240 Let's see. 97 00:07:18,240 --> 00:07:26,170 See and hear see is also visible because it is internal in nature and the internal variables are always 98 00:07:26,170 --> 00:07:28,170 visible within the same model. 99 00:07:28,360 --> 00:07:31,760 And now let us try B. 100 00:07:31,760 --> 00:07:34,590 Now B is actually predicted in nature. 101 00:07:34,750 --> 00:07:42,970 Now the protected keyword is only applicable to make value visible inside the subclass not in some other 102 00:07:42,970 --> 00:07:43,470 class. 103 00:07:43,500 --> 00:07:43,840 Right. 104 00:07:43,860 --> 00:07:45,780 So always remember this. 105 00:07:45,820 --> 00:07:52,730 The protected keyword will not make your value visible in some other class that has nothing to do with 106 00:07:52,740 --> 00:07:53,360 it. 107 00:07:53,440 --> 00:07:56,420 Now similarly if I use Burreson door. 108 00:07:56,520 --> 00:08:02,790 Then again it is going to show some error that it is favored in nature and we cannot have this value 109 00:08:02,910 --> 00:08:03,950 inside that test. 110 00:08:03,960 --> 00:08:06,120 Plus what I. 111 00:08:06,250 --> 00:08:13,700 So here lately I have some comments for you so here person Doherty and person D'Arby are not visible 112 00:08:13,760 --> 00:08:21,170 because they are private and protected in nature by person C and person or D are actually visible because 113 00:08:21,230 --> 00:08:24,550 they are internal and public in nature. 114 00:08:25,100 --> 00:08:32,000 So I guess no you know what our visibility mortifies in case of Codlin and how it Vashti's in comparison 115 00:08:32,090 --> 00:08:35,290 to some other programming language such as Java. 116 00:08:35,350 --> 00:08:38,670 But I so this is all for this video. 117 00:08:38,780 --> 00:08:40,240 Thank you and have a good day.