Skip to content
Sharp

Object-oriented programming · interview question

Which approach ensures that a method returns an unmodifiable list in Java?

Multiple choiceMediumchapter-3-curatedpremiumoopobject-responsibility
Choose one answer
Answer and explanation

Correct answer

C. Wrapping the list with Collections.unmodifiableList()

Why

Using Collections.unmodifiableList() wraps the original list and provides an unmodifiable view of it, preventing any modifications to the list by external code.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →