LearnFrenzy
Sign in Take a free test

Arrays in Java · Java Arrays MCQ · Question 12

clone() on a 2D array Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 12 Back to Exercise

What does int[][] copy = grid.clone(); copy?

  • A Every element deeply
  • B Only the outer array – both copies share the same row arrays Correct
  • C Nothing
  • D Only the first row
Correct Answer: Option B

Changing copy[0][0] also changes grid[0][0]; clone each row for a deep copy.

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