The protected keyword is a modifier that can be used in the declaration of methods or variables. (Note that the protected keyword cannot be used in the declaration of local variables.) A protected variable or method is only visible within its class, within its subclasses, or within the class package. Note that the subclasses may reside within different packages, however.