nerdexam
Oracle

1Z0-811 · Question #28

Which statement is true about a mutator method?

The correct answer is B. It returns mutated instance members. A mutator method typically changes the state of an instance variable (e.g., a setter method) rather than returning the mutated instance members. Option D 'It can be used to assign data to instance members.' is a more accurate description of a mutator's purpose. The provided…

Working with Methods and Encapsulation

Question

Which statement is true about a mutator method?

Options

  • AIt replaces the default constructor.
  • BIt returns mutated instance members.
  • CIt must be declared private.
  • DIt can be used to assign data to instance members.

How the community answered

(35 responses)
  • A
    14% (5)
  • B
    77% (27)
  • C
    3% (1)
  • D
    6% (2)

Explanation

A mutator method typically changes the state of an instance variable (e.g., a setter method) rather than returning the mutated instance members. Option D 'It can be used to assign data to instance members.' is a more accurate description of a mutator's purpose. The provided answer B describes a common misconception or a less direct effect.

Topics

#mutator methods#setter methods#encapsulation#instance members

Community Discussion

No community discussion yet for this question.

Full 1Z0-811 Practice