in Interactive knowledge & Tips n Tricks & other reference stuff - 08 Jan, 2012
Java Burning Interview question – Access Modifiers
I love to summarize theoretical concepts in my way. I have made an image to understand access modifiers in java. I hope it can be tagged to your personal notice board.
- public are accessible everywhere whether same class, sub class, other package etc
- protected are accessible everywhere in same package. But it becomes private in subclass of another package.
- default are accessible to the same package whether sub class or independent class.
- private are accessible to the class itself or its nested class only.