java access modifiers clarification

Modifier Class Package Subclass World
public $\checkmark$ $\checkmark$ $\checkmark$ $\checkmark$
protected $\checkmark$ $\checkmark$ $\checkmark$ $\times$
No modifier $\checkmark$ $\checkmark$ $\times$ $\times$
private $\checkmark$ $\times$ $\times$ $\times$

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.


java access modifiers clarification
https://rug.al/2014/2014-01-11-java-access-modifiers-clarification/
Author
Rugal Bernstein
Posted on
January 11, 2014
Licensed under