Visibility

Now that we understand inheritance, we can try to explain the visibility modifiers, such as private and public. There is still one more concept we need to fully understand visibility, but we at least now enough to talk about it now.

Situationpublicdefaultprotected private protectedprivate
Accessible to non-subclassYesYesYes NoNo
Accssible to subclassYesYesYes NoNo
Inherited by subclassYesYesYes YesNo

This table is abbreviated to contain only what we've learned so far. Notice that with what we know, public, default and protected are the same. Later we'll see the differences.

Default is the visibility assigned to a class, method or variable if you do not explicitly assign it some other visibility, such as private or public.

Return to Lesson: Advanced Classes

Return to the Main Menu.