Public, Private, Protected Access Modifiers and No Modifiers in Java
Levels of AccessPrivateNo ModifierProtectedPublicSame ClassYesYesYesYesSame Package Sub ClassNo YesYesYesSame Package Non-Sub ClassNoYesYesYesDifferent Package Sub ClassNoNoYesYesDiffernt Package Non-Sub ClassNoNoNoYes Note – In this table, Sub Class means a child-parent relationship is involved between the two classes. If you do not understand the above table, do not worry because you will understand it after going through the complete article. Why I am writing this in-depth