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

Leave a comment