No video

Access Modifiers in java by Example [Most Basic Java Interview Question !!] | Code Decode

  Рет қаралды 17,685

Code Decode

Code Decode

Күн бұрын

In this video of code decode we have explained what is access modifier in java which is commonly asked interview question in java
Udemy Course of Code Decode on Microservice k8s AWS CICD link:
openinapp.co/u...
Course Description Video :
yt.openinapp.c...
Access Modifiers in java by Example
Access Modifiers in java with example and animations - Theory | java class modifiers | Public, Protected, Private, Default
- Java access modifiers (default, public, private and protected) let you say which files can see methods and variables.
Access Modifiers :
Public: If we class then we can use public.
Protected: Visible to the package and all sub classes. Protected keyword is used.
Private: only if that class needs that variable then we can use private.
The access modifiers in java are:
default, public, private and protected.
Java Protected is the most tricky of all the four. Public private protected are specified with keyword but default access modifier in java does not need any keyword explicitly.
This tutorials following questions:
how to use access specifiers in java with examples, live coding example
public private protected java makes variables secure in java. these access specifiers make life of programmers much easy to have more control over variable access.
public and private modifiers are opposite while protected modifier is complex and rolls over extending classes.
This video tutorial explains the concepts of Java Access Modifiers. I have explained the importance of access modifiers and also explained how public, default access modifiers work at class level. The access modifiers for members- public,protected, default and private have been explained and demonstrated with an example.
Java protected access modifiers or protected access modifier in java make sure that no other class in another package can access your protected variables who doesnot extend your class.
Though java protected keyword does allow all your classes in same package even if they dont extend your class in which variable is defined to be accessing your protected variable.
java private access modifier is the most restrictive access modifier as it does not allow any other class to access your variable.
java private and protected keywords we have covered. These are also called java class modifiers.

Пікірлер: 17
@alstutorial5075
@alstutorial5075 10 ай бұрын
Thank you mam. You taught it very smoothly😊
@CodeDecode
@CodeDecode 9 ай бұрын
You’re welcome
@Kaox
@Kaox 3 жыл бұрын
Thanks for sharing
@CodeDecode
@CodeDecode 3 жыл бұрын
👍
@svaduvan85
@svaduvan85 3 жыл бұрын
Thanks for your effort
@CodeDecode
@CodeDecode 3 жыл бұрын
👍
@praveenkumar-xx2el
@praveenkumar-xx2el 4 жыл бұрын
Hi maa'm
@CodeDecode
@CodeDecode 4 жыл бұрын
Hi Praveen
@ramdunge7962
@ramdunge7962 4 жыл бұрын
Sorry I am not understand
@CodeDecode
@CodeDecode 4 жыл бұрын
Please tell me what did you find difficult in understanding. I will clarify that.
@ramdunge7962
@ramdunge7962 4 жыл бұрын
very confused
@CodeDecode
@CodeDecode 4 жыл бұрын
Please tell me what is confusing you in this video
@ramdunge7962
@ramdunge7962 4 жыл бұрын
Access Modified when will you access modifed
@CodeDecode
@CodeDecode 4 жыл бұрын
Ok so if you want your variable to be visible in only your specific class then keep it private, then no one can see that expect your own class. For making your variable visible to only your set of classes bundled in your package then make it default by using no access modifier. If you want package set+ sub classes in whole project to see your variable then make it protected. If you want to use your variable in whole application as in all classes can assess that variable using your object of that class then use public. That's all. Please tell me if above 4 points are clear then we will proceed further with your queries.
@ramdunge7962
@ramdunge7962 4 жыл бұрын
what is access modified work explain in real life exmple
@CodeDecode
@CodeDecode 4 жыл бұрын
Ok so in real life, consider private as your tooth brush which only you want to use. Your father is like default only you and your kids can use father name. Protected can be thought as your car which you , your. Family and your extended family can use. And finally public real time object can be considered as the water tank you put outside your home which everyone can use and see.
拉了好大一坨#斗罗大陆#唐三小舞#小丑
00:11
超凡蜘蛛
Рет қаралды 14 МЛН
I Took a LUNCHBAR OFF A Poster 🤯 #shorts
00:17
Wian
Рет қаралды 6 МЛН
Java Interview Questions | Access Modifiers : The Complete Guide | Tutorial #6
9:53
The Kiran Academy - Java By Kiran
Рет қаралды 2 М.
Access Modifiers in Java - PUBLIC, PRIVATE, PROTECTED and DEFAULT
17:53
Indian Programmer
Рет қаралды 8 М.
Access Modifiers Java Tutorial #82
11:27
Alex Lee
Рет қаралды 230 М.
Top 30 JAVA Interview Questions and Answers for Beginners
1:25:45
Interview Happy
Рет қаралды 16 М.
Access Modifier in Java-Public,Protected,Private and Default
10:10