← Quiz: Java Methods: all 10 questions
Quiz: Java Methods · Question 9 of 10
Which varargs declaration is valid?
Which varargs declaration is valid?
- A.void f(String label, int... nums)
- B.void f(int... nums, String label)
- C.void f(int... a, int... b)
- 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 →