Question 8
Back to Exercise
A getter returns a private ArrayList field directly. What is the risk?
- A None, the field is private
- B Callers can modify the list and bypass the class's rules Correct
- C It does not compile
- D The list is copied automatically
Correct Answer: Option B
private protects the variable, not the object it refers to.
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!