Java Foundations — Question 27
Which statement is true about a mutator method?
Answer options
- A. It replaces the default constructor.
- B. It returns mutated instance members.
- C. It must be declared private.
- D. It can be used to assign data to instance members.
Correct answer: B
Explanation
The correct answer, B, is true because a mutator method is designed to modify the values of instance members. Options A and C are incorrect as mutator methods do not replace constructors or need to be private, and option D, while partially true, does not accurately describe the primary function of mutator methods.