What is the difference between a mutator method and an accessor method? Provide an example of each.

What will be an ideal response?


Methods that set or change field values are called mutator methods; methods that retrieve values are called accessor methods. In Java, mutator methods conventionally start with the prefix set, and accessor methods conventionally start with the prefix get.?Mutator example:public void setEmpNum(int emp)
{
   empNum = emp;
}
?Accessor example: public int getEmpNum()
{
   return empNum;
}

Computer Science & Information Technology

You might also like to view...

Java's for loop is much less flexible than Alice's for loop.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

XML is most commonly used to:

a) communicate with wireless devices b) store and format data for exchange between apps c) display information on the Internet d) validate HTML files.

Computer Science & Information Technology

In a Windows network environment, what two types of network security models can be configured?

What will be an ideal response?

Computer Science & Information Technology

Which of the following is recognition that data used by an organization should only be used for the purposes stated by the information owner at the time it was collected?

A. accountability B. availability C. privacy D. confidentiality

Computer Science & Information Technology