228k views
3 votes
Set methods are also commonly called _____ methods, and get methods are also commonly called _____ methods.

query, mutator.
accessor, mutator.
mutator, accessor.
query, accessor.

1 Answer

3 votes

Answer:

mutator, accessor

Step-by-step explanation:

Set methods are commonly called mutator methods, and get methods are commonly called accessor methods.

This is because set methods are used to mutate the state of a variable. Get methods, on the other hand are used to access the current state of the variable.

For example:

class Demo{

//Member variable

private int var;

//Accessor method

public int getVar(){

return var;

}

//Mutator method

public void setVar(int value){

var=value;

}

}

User Jimmy Ilenloa
by
6.0k points