Skip to content
Sharp

Object-oriented programming · interview question

What does calling List.copyOf on a mutable list evaluate to?

Multiple choiceEasychapter-3-curatedpremiumoopdefensive-copying
Choose one answer
Answer and explanation

Correct answer

C. A new immutable list containing the same elements

Why

Calling List.copyOf on a mutable list returns a new immutable list containing the same elements as the original list. The original list remains mutable, but the new list cannot be modified.

Test yourself on Object-oriented programming

A free test with instant, explained results. No account needed.

Start free test
All Object-oriented programming questions →