Write a mutator method (both header and body) for an instance variable of type int with the identifier id in the Employee class. Your method should validate the parameter to the method to ensure that improper values are not accepted. Only ids in the range 0 - 999 (inclusive) are considered valid. Should your method encounter invalid input, it should ignore it entirely and not modify the previous value of id. You are not required to print out any kind of error message or take other steps beyond ensuring that the instance variable is only modified when given valid input.
a) setId(int id) { /* method body / }
b) setId(int id) { if (id >= 0 && id <= 999) this.id = id; }
c) setEmployeeId(int id) { / method body / }
d) setId(int newId) { / method body */ }

Q&A Education