Why do we need protected modifier methods when we can directly set the variable to protected?
For e.g: In the below code, they set the instance variable SocialSecurityNumber to private and define a protected setter method to set its value? Why can't we directly set the variable SocialSecurityNumber to protected?
public class SSNWrapper {
private int SocialSecurityNumber ;
public SSNWrapper (int ssn) { socialSecurityNumber = ssn ;}
public int getSSN () { return SocialSecurityNumber; }
protected void setSSN(int SSN) { socialSecuritynumber = ssn ; }
}