This is getting started.
And welcome to the next video of this object oriented programming.
Now so far we have covered almost all topics related to the classes and objects.
Now let us talk about the visibility modifiers in case of Cartland in case of Cartland.
We have the visibility more defiance of public protected internal and private and now in the previous
videos we saw that Bideford all the classes and functions are actually Bideford public in nature.
So in Cortland everything is public in nature by default.
Always remember this.
So here inside the intelligent Id let us explore the visibility more.
Now here I am working under my first daughter Katie file.
So as our top level work classes and functions that I really define here will be by default public in
nature.
As for example here latest example of function trend class person.
So Bideford this function is actually public in nature.
Right.
As we all know from the previous videos and now here this class is again public in nature by default.
Now if you specify here let's see private and also private.
Here then this method and this class person is only visible inside my first dark gate.
Now I suppose if you create one more plus such as let's see new Gorlin file.
See my second so here inside my second Dorte guilty.
These two functions and classes will not be visible just because we have simply declared a private right.
And earlier it was public.
So these two metrics and class can be accessed inside my class Dorte guilty of us public and now in
gardening we have one more mortified of late in doing so if you declared it internal And also this will
as internal then this method and this class will be visible.
Didn't see more do you know what does a Mordy will in case of Coquelin programming.
So if you what is inside the project this Gorlin programming is actually even more D-Will so Amandi
will in case of Cartland programming can be a bunch of Koechlin files or some other files such as a
Mordy will can be intelligent ID Mordy will groovey more D-Will maybe in more detail and so on like
that.
So here if your declared internal So this function and this class will only be visible rigidness seem
more do it right.
So my second thought Guti will have access to this method and also this clus similar to public and now.
Next we have at the end protected and this protected is not applicable for the high level functions
and classes.
So if you declare a function right inside the K-T file then this verdict is not applicable.
So here it shows some error.
The mortified predictor is not applicable at top level function.
Now the same thing applies to the class as well.
This for is not applicable here as well.
So here let us remove it.
And by default we are back to again public.
Now this was all about their top level functions and classes no Valter both inside the class person.
Suppose if I define some variables and functions and also define our derived class then what will happen.
So here I have an open class of person which is actually acting as a superclass for this class of Indian
right here.
Now I suppose if I define private value equal to one inside the class of FERSEN.
So what will happen inside the class of Indian.
So you can not access this variable inside the class of Indian Just because this is private in nature.
So here.
This variable is not visible inside the class of Indian Just because we have marked it as private.
And now let us define predicted value be equal to.
Now here we are using the predicted keyword or the mortified.
So this value of b is actually visible or can be accessed inside the class of Indian just because it
is predicted in nature.
And now next we have internal values C equal to 3.
So since this is internal so again B along with C will be not visible inside the class of Indian.
And now let us go in for the public.
Val be equal to let's see then an asset.
By default all the classes and functions and also the properties are actually public in nature.
So here we don't have to specify this value will be as public explicitly because by default it is public
in nature.
So this value of the is again visible inside the class of Indian doctors we can access it here right
now.
Or do we mean by exactly by visibility of the functions and classes.
Now suppose inside this class Indian.
Suppose if I create a function of let's see test and now insert that test.
Suppose I want to print these values.
So here I would simply use the print function.
Right now inside the print method.
Suppose if I type here.
Let's see the latest beat.
So here the compiler will not show some error because this D can be accessed inside the class of Indian
as it is by default probably known to destroy this value of c latest type.
See no gain.
C is also visible inside the class of Indian because it is internal in nature.
And now let's just talk about this protected be ledes state B.
And here again began to be accessed.
Since it is declared in nature not it has come to the library value of the latest type it here but here
the compiler is not happy because it cannot access a.
It is invisible just because we have MMOG it private in nature.
Right now this was about the superclass and the derived class.
Now what about some other class where we actually define let's say remove this function best and now
he had ordered all let us create one more class of let's see first class and now insert this last it
started to create a method.
Let's see.
Pasting again to test all the visibility of these variables.
Inside this testing method if I created the object of this person let's say value person equal to person
right now inside their testing method that is.
Insert the class that has nothing to do with this class of person.
Let's see how these mortifies plays their key role.
So here inside this let us print.
Let's see if print flares and Dorte the.
So here is now again visible because it is public in nature.
Right now let us try.
Let's see.
See and hear see is also visible because it is internal in nature and the internal variables are always
visible within the same model.
And now let us try B.
Now B is actually predicted in nature.
Now the protected keyword is only applicable to make value visible inside the subclass not in some other
class.
Right.
So always remember this.
The protected keyword will not make your value visible in some other class that has nothing to do with
it.
Now similarly if I use Burreson door.
Then again it is going to show some error that it is favored in nature and we cannot have this value
inside that test.
Plus what I.
So here lately I have some comments for you so here person Doherty and person D'Arby are not visible
because they are private and protected in nature by person C and person or D are actually visible because
they are internal and public in nature.
So I guess no you know what our visibility mortifies in case of Codlin and how it Vashti's in comparison
to some other programming language such as Java.
But I so this is all for this video.
Thank you and have a good day.