This allows the accessed object to be changed more easily without affecting objects that refer to it. Broadly speaking,
public means everyone is allowed to access,
private means that only members of the same class are allowed to access, and
protected means that members of subclasses are also allowed.
read more >>