Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

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. 
Comment

PREVIOUS NEXT
Code Example
Java :: fill two dimensional array java 
Java :: arraylist to int array conversion in java 
Java :: How to find the logged-in user in Spring Boot? 
Java :: android application class 
Java :: java enums 
Java :: get day from date month year java 
Java :: how to change double to int in java 
Java :: android @Parcelize not resolving 
Java :: springboot mongodb test 
Java :: if is true javascrtiptr 
Java :: java gitignore 
Java :: java get length of a string 
Java :: how to find some of digits in java 
Java :: java sum of array elements 
Java :: android studio download 
Java :: java string to byte array utf8 
Java :: java swing dialog box 
Java :: java swing menu click event 
Java :: dot operator java 
Java :: java add elements array 
Java :: calling activity method from fragment: 
Java :: how to check palindrome in java 
Java :: java inheritance 
Java :: how to substring in java 
Java :: android java get value from listview item 
Java :: java program to remove duplicate words in a string 
Java :: convert void * to int 
Java :: public class in java 
Java :: what is transient in java 
Java :: view all certificates from keystore java 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =