Java OCA OCP Practice Question 1174

Question

Which of the following method signatures does not contain a compiler error?

  • A. public void m(String key, String... harmonies)
  • B. public void m(int note, String... sound, int music)
  • C. public void m(String... keys, String... pitches)
  • D. public void m(String... notes, String melodies)


A.

Note

A method may contain at most one varargs parameter.

It must appear as the last argument in the list.

Option A is correct.

Options B, C, and D are incorrect.




PreviousNext

Related