LearnFrenzy
Sign in Take a free test

Encapsulation · Encapsulation MCQ · Question 13

Generating a setter for every field Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 13 Back to Exercise

Why is generating a public setter for every private field poor encapsulation?

  • A It is slower
  • B It lets callers change any value at any time, so the fields are effectively public Correct
  • C Setters cannot be public
  • D Fields must be final
Correct Answer: Option B

Add setters only where change is a valid operation.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links