Machine-translated by Google. Questions are authored in English.
Top

Discussion

What Collections.unmodifiableList returns - which of the following is true?

  • A.The same list object, with an internal flag set to reject modification.
  • B.A list whose elements are themselves made immutable.
  • C.An unmodifiable view, through which changes to the underlying list are still visible.
  • D.An independent immutable copy, unaffected by later changes to the original.

Answer: C

It wraps rather than copies, so the wrapper refuses modification while anything still holding the original list can change it and those changes show through the view. Genuine immutability needs a copy, and neither approach makes the elements themselves immutable.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.