Question 11
Back to Exercise
For which field type is a defensive copy unnecessary?
- A int[]
- B String (immutable) Correct
- C ArrayList<String>
- D java.util.Date
Correct Answer: Option B
Immutable objects such as String, Integer and LocalDate can be shared safely.
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!