Access Modifiers in Java


We always use Public, Private, Protected in our Selenium scripts. Before using these, we should know how and where to use these access modifiers. Here is the table showing where we can call these modifiers:

Access Modifier
within class
within package
outside package by 
subclass only
outside 
package
Private
Y
N
N
N
Default
Y
Y
N
N
Protected
Y
Y
Y
N
Public
Y
Y
Y
Y