24 Dec 2017

Compression of private, default, protected and public modifier.


Compression of private, default, protected and public:
Visibility
private
default
protected
public
Within the same class
P
P
P
P
From child class of same package
O
P
P
P
From non-child class of same package
O
P
P
P
From child class of outside package
O
O
P
(but we should use child reference only)
P
From non-child class of outside package
O
O
O
P

Modifier
Classes
Methods
variables
Blocks
Interfaces
enum
Constructers
outer
Inner
Outer
Inner
outer
Inner
public
P
P
P
P
O
P
P
P
P
P
private
O
P
P
P
O
O
P
O
P
P
protected
O
P
P
P
O
O
P
O
P
P
default
P
P
P
P
O
P
P
P
P
P
final
P
P
P
P
O
O
O
O
O
O
static
O
P
P
P
P
O
P
O
P
O
synchronized
O
O
P
O
P
O
O
O
O
O
abstract
P
P
P
O
O
P
P
O
O
O
native
O
O
P
O
O
O
O
O
O
O
strictfp
P
P
P
O
O
P
P
P
P
O
transient
O
O
O
P
O
O
O
O
O
O
volatile
O
O
O
P
O
O
O
O
O
O