Access Modifiers in Java
Access modifiers control who can see a class member. private: only the same class. default (no word): same package. protected: package + subclasses. public: everywhere.
Start strict (private) and open only when needed. Making everything public “for speed” breaks encapsulation.
Recite narrow to wide — private → default → protected → public. That sentence alone clears most MCQs.
Let's take this on the board with one tiny Main class — no extra files. Access Modifiers in Java — secret is private; outside code uses a getter. Start from main, go line by line, and stop at each print. That output is the proof for Access Modifiers.
Narrow → wide: private, default, protected, public.