LearnFrenzy
Sign in Take a free test

Arrays in Java · Java Arrays MCQ · Question 8

Comparing arrays with equals() Answer, explanation & discussion

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

What does new int[]{1, 2}.equals(new int[]{1, 2}) return?

  • A true
  • B false – arrays inherit Object.equals, which compares references Correct
  • C Compile error
  • D It throws
Correct Answer: Option B

Use Arrays.equals(a, b) for contents.

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