Answers for "Difference between Public, Private and Protected modifier in Java?"

0

Difference between Public, Private and Protected modifier in Java?

• In Java, access modifier which specifies accessibility of class, 
	methods and variables. There are four access modifiers in 
	Java namely Public, Private, Protected and Default. 
• The difference between these access-modifies is that; 
o The most importantly is the level of accessibility. 
o Public is accessible to anywhere 
o Private is only accessible in the same class which is declared 
o Default is accessible only inside the same package 
o Protected is accessible inside the same package and also 
	outside the package but only the child classes. 
• We cannot use private or protected modifier with a top--level class. 
• We should also keep in mind that access modifier cannot 
	applied for local variable public, private or protected in Java.
Posted by: Guest on May-16-2021

Code answers related to "Difference between Public, Private and Protected modifier in Java?"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language