🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Java Arrays: all 10 questions

Quiz: Java Arrays · Question 4 of 10

Which prints the contents of int[] nums as [1, 2, 3]?

Which prints the contents of int[] nums as [1, 2, 3]?

  1. A.System.out.println(nums)
  2. B.System.out.println(Arrays.toString(nums))
  3. C.System.out.println(nums.toString())
  4. D.System.out.println(String(nums))
Answer & explanation

Correct answer: System.out.println(Arrays.toString(nums))

Arrays.toString formats the values. Printing the array itself shows a reference.

Can you get the rest right without peeking?

Take the timed Quiz: Java Arrays quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →