Multiple choice technology

public class Va { public static void main(String[] args) { doCalc(1,2); doCalc(2); } //Point1. code to be inserted here } Which of the following inserted individually at Point1 will compile?

  1. Static void doCalc(int x, int… args) {}

  2. Static void doCalc(int… args, int x) {}

  3. Static void doCalc(int[] args)

  4. Static void doCalc(int args…)

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

Varargs (...) must be the last parameter in a method signature. Option A places varargs last, so doCalc(1,2) maps x=1, args=[2], and doCalc(2) maps x=2, args=[]. Option B fails because varargs cannot precede a required parameter. Option C won't compile for the given calls, and option D has incorrect syntax.