Access Levels of Java Class

Modifier     Class       Package       Subclass       World
public          Y              Y                    Y                    Y
protected    Y              Y                    Y                    N
no mod        Y             Y                    N                    N
private         Y             N                   N                    N

It is probably worth pointing out that in the case of no modifier, whether or not the subclass can see it’s superclass’s methods/fields depends on the location of the subclass. If the subclass is in another package, then the answer is it can’t. If the subclass is in the same package then it CAN access the superclass methods/fields

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s