Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java supports methods with variable number of arguments. Which of these options

ID: 3840092 • Letter: J

Question

Java supports methods with variable number of arguments. Which of these options is considered valid method declaration in Java when the following statement is executed?

myObj.variableArgsMethod(10, 20, 30, 40);

public void variableArgsMethod(Object...varargs) { . . . }

public void variableArgsMethod(String...varargs) { . . . }

public void variableArgsMethod(int...varargs) { . . . }

Options (a) and (b)

Options (a) and (c)

Options (b) and (c)

Options (a), (b), and (c)

None of the above

a.

public void variableArgsMethod(Object...varargs) { . . . }

b.

public void variableArgsMethod(String...varargs) { . . . }

c.

public void variableArgsMethod(int...varargs) { . . . }

d.

Options (a) and (b)

e.

Options (a) and (c)

f.

Options (b) and (c)

g.

Options (a), (b), and (c)

h.

None of the above

Explanation / Answer

answer is,

e. Options (a) and (c)

options (a) and (c) are valid . Option (b) is not valid. It will generate a error during compilation. Since, int cannot

be converted into String.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote