Which are true about instance variables of a class (check all that apply): Group of answer choices They should usually be declared private. Member instance methods of the same class must use this. before their names in order to access them. Member instance methods of the same class must use mutator methods to modify their values. Mutators should protect them by filtering bad parameter values before assigning those values to them. Loop counters and other helper variables should be declared as instance variables so that such counters and helpers don't have to be re-declared local to every member method, individually.

Respuesta :

Answer:

  1. They should usually be declared private.  
  2. Member instance methods of the same class must use mutator methods to modify their values. Mutators should protect them by filtering bad parameter values before assigning those values to them.  

Explanation:

Instance variables of a class are usually declared in private scope. This is to ensure data consistency. If the instance variable is in public scope, the value in the variable can be directly accessed outside of class and this pose a risk the instance variable will be assigned with an unexpected value or invalid value.

Mutator method is required whenever there is any update or change to the existing value of a instance variable. We can introduce a validation mechanism in the mutator method to ensure only the valid value can be assigned to the instance variable.  

ACCESS MORE
EDU ACCESS
Universidad de Mexico