← Quiz: Java Methods: all 10 questions
Quiz: Java Methods · Question 5 of 10
What does sum(int... nums) receive as nums when called as sum(1, 2, 3)?
What does sum(int... nums) receive as nums when called as sum(1, 2, 3)?
- A.three separate ints
- B.an int array {1, 2, 3}
- C.a List<Integer>
- D.the number 6
Answer & explanation
Correct answer: an int array {1, 2, 3}
Varargs parameters are arrays inside the method.
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 →