3. Class Creation
Mutator Methods — Quiz
Test your understanding of mutator methods with 5 practice questions.
Practice Questions
Question 1
What is the main purpose of a mutator method in a class?
Question 2
Which method name is most commonly used for a mutator that changes a student's score?
Question 3
Consider the method below in a class named $BankAccount$.
public void deposit(double amount)$ ${$ $ balance = balance + amount;$ $}
What does this method do?
public void deposit(double amount)$ ${$ $ balance = balance + amount;$ $}
What does this method do?
Question 4
Why are mutator methods often marked with the access modifier $public$?
Question 5
A class has the private instance variable $int score$. Which method is a valid mutator?
