answersLogoWhite

0


Best Answer

Mutator: Put something into the class (change something). By convention, has a name that starts with "set", for example, "getName".

Accessor: Get something out of the class (find out the class's state). By convention, has a name that starts with "get", for example, "getName". For logical values, "is" is used instead, for example, "isActive".

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between mutuator and accessor methods?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is an accessor?

An accessor is a method in a Java Bean that is used to access the private variables of the class. Usually instance variables in a bean are declared as private and they can be accessed only via these accessor methods. Ex: public class Employee { private String name = ""; private int age = 0; public String getName(){ return this.name; } public void setName(String nm){ this.name = nm; } public int getAge(){ return this.age; } public void setAge(int ag){ this.age = ag; } } In the above example name and age are instance variables and the methods beginning with get and set are the accessor methods.


What is the difference between methods and events in c?

There are no methods or events in C.


Examples of accessor method?

Accessors are methods defined inside classes to access the private variables of the class. It is always a good practice to have instance variables as private so that, other classes cannot access them directly. This would avoid unwanted modification of data. These variables can be accessed only via their respective accessor methods. Ex: public class Test { private String name = ""; public String getName(){ return this.name; } Public void setName(String val){ this.name = val; } } Here getName and setName are the accessor methods for the variable name.


Define the java terms of accessor?

Accessors are methods defined inside classes to access the private variables of the class. It is always a good practice to have instance variables as private so that, other classes cannot access them directly. This would avoid unwanted modification of data. These variables can be accessed only via their respective accessor methods. Ex: public class Test { private String name = ""; public String getName(){ return this.name; } Public void setName(String val){ this.name = val; } } Here getName and setName are the accessor methods for the variable name.


What are the naming conventions for accessor methods and mutator methods?

Accessors: getValue Mutators: setValue Example: class MyClass { int num; int getNum() { return num; } void setNum(int num) { this.num = num; } }

Related questions

What is an accessor?

An accessor is a method in a Java Bean that is used to access the private variables of the class. Usually instance variables in a bean are declared as private and they can be accessed only via these accessor methods. Ex: public class Employee { private String name = ""; private int age = 0; public String getName(){ return this.name; } public void setName(String nm){ this.name = nm; } public int getAge(){ return this.age; } public void setAge(int ag){ this.age = ag; } } In the above example name and age are instance variables and the methods beginning with get and set are the accessor methods.


What is the difference between methods and events in c?

There are no methods or events in C.


What is the difference between science and scientific methods?

== ==


Examples of accessor method?

Accessors are methods defined inside classes to access the private variables of the class. It is always a good practice to have instance variables as private so that, other classes cannot access them directly. This would avoid unwanted modification of data. These variables can be accessed only via their respective accessor methods. Ex: public class Test { private String name = ""; public String getName(){ return this.name; } Public void setName(String val){ this.name = val; } } Here getName and setName are the accessor methods for the variable name.


Define the java terms of accessor?

Accessors are methods defined inside classes to access the private variables of the class. It is always a good practice to have instance variables as private so that, other classes cannot access them directly. This would avoid unwanted modification of data. These variables can be accessed only via their respective accessor methods. Ex: public class Test { private String name = ""; public String getName(){ return this.name; } Public void setName(String val){ this.name = val; } } Here getName and setName are the accessor methods for the variable name.


What are the differences between Montessori and kindergarten methods?

No difference


What is the difference between volhard and mohr methods?

ghjghjgh


What are the naming conventions for accessor methods and mutator methods?

Accessors: getValue Mutators: setValue Example: class MyClass { int num; int getNum() { return num; } void setNum(int num) { this.num = num; } }


What is the difference between Scientific Unscientific methods of Business research?

Discuss scientific versus unscientific methods in research


What is the difference between the methods used to broil chicken and turkey?

The time in which you cook it.


What is the difference between internal criticism and external criticism in reseach methods?

jok


What is the main difference between numerical methods used to determine integrals?

Because it is STUPID