Chapter 11: Problem 14
What is an accessor method? What is a mutator method?
Short Answer
Expert verified
Answer: Accessor methods, also known as getter methods, are used to access or get the value of an object's attribute without directly accessing the attribute, promoting encapsulation. Mutator methods, also known as setter methods, allow the user to modify or set the value of an object's attribute indirectly, maintaining data hiding and integrity. Both methods serve the purpose of promoting encapsulation by restricting direct access to an object's attributes and controlling how the values are accessed or modified.