Accessors:
API's or methods which were used to get the current state of an object.
Mutators:
API's or methods which were used to change the state of an object.
Ex: set(int a);
An object has mainly two things state and behaviour.. State denotes the instance variables of a class and Behaviour denotes the methods or API's in class[ which is blueprint of an object] .
class Animal{
private int color;
public void getColor(){
return color;
}
public setColor(int color){
this.color = color;
}
}
In this program, getColor is an Accessor setColor is Mutator
API's or methods which were used to get the current state of an object.
Mutators:
API's or methods which were used to change the state of an object.
Ex: set(int a);
An object has mainly two things state and behaviour.. State denotes the instance variables of a class and Behaviour denotes the methods or API's in class[ which is blueprint of an object] .
class Animal{
private int color;
public void getColor(){
return color;
}
public setColor(int color){
this.color = color;
}
}
In this program, getColor is an Accessor setColor is Mutator
No comments:
Post a Comment
Post a Comment
Note: Only a member of this blog may post a comment.