"Functions" Please respond to the following:

Question Description

Accessor and mutator functions can be used in conjunction and are often associated with the words SET and GET. Describe each of these functions and provide an example of a situation in which they can be used together.

Final Answer

Getters and Setters are the cornerstone of data access in object oriented programming. These are important, because it allows different objects to interact with data stored inside of an object without directly touching the variable. 

Think of it like this: There is a Fred object and he has a variable "wallet". Now he doesn't want people directly changing what's in his wallet. So, they have to ask him to get it's value or to change it. That's the same as getter's and setter's.

The getter is used to get the current value of the object's member variable. The setter is used to change it. A simple example is if the program wants to set the value, but only if it is empty. First, it would check the value with the getter. If it is empty, it would call the setter with the new value to change it to.

Frederick W (148)
New York University

The tutor managed to follow the requirements for my assignment and helped me understand the concepts on it.

The tutor was knowledgeable, will be using the service again.

Awesome quality of the tutor. They were helpful and accommodating given my needs.


Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors