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

Quiz: Java Methods · Question 9 of 10

Which varargs declaration is valid?

Which varargs declaration is valid?

  1. A.void f(String label, int... nums)
  2. B.void f(int... nums, String label)
  3. C.void f(int... a, int... b)
  4. D.void f(int...)
Answer & explanation

Correct answer: void f(String label, int... nums)

A method can have only one varargs parameter, and it must be the last one.

Can you get the rest right without peeking?

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

Start the quiz →