LearnFrenzy
Sign in Take a free test

Arrays in Java · Java Arrays MCQ · Question 16

Adding to a List from Arrays.asList Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 16 Back to Exercise

What happens with Arrays.asList("a", "b").add("c")?

  • A The list grows to 3
  • B UnsupportedOperationException – the list has a fixed size Correct
  • C Compile error
  • D Nothing
Correct Answer: Option B

Wrap it: new ArrayList<>(Arrays.asList(…)) or use List.of for an immutable list.

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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links