Multiple choice technology programming languages

Given: 1. class Voop { 2. public static void main(String [] args) { 3. doStuff(1); 4. doStuff(1, 2); 5. } 6. // insert code here 7. } Which, inserted independently at line 6, will compile? (Choose all that apply.)

  1. static void doStuff(int... doArgs) { }

  2. static void doStuff (int [] doArgs) { }

  3. static void doStuff(int doArgs...) { }

  4. static void doStuff(int... doArgs, int y) { }

  5. static void doStuff(int x, int... doArgs) { }

Reveal answer Fill a bubble to check yourself
A,E Correct answer
Explanation

Java varargs (variable arguments) uses '...' syntax. A (int... doArgs) is valid varargs parameter at the end. E (int x, int... doArgs) is valid with required parameter first, varargs last. C (int doArgs...) is invalid - ellipsis must be between type and name. D (int... doArgs, int y) is invalid - varargs must be the last parameter. B is incorrect not because of array syntax but because doStuff(1) and doStuff(1,2) calls: B takes int[] which requires explicit array construction, while varargs handles these calls directly.