Java OCA OCP Practice Question 873

Question

Which of the following statements are true?

You can always change a method signature from

  • I. call(String[] arg) to call(String... arg)
  • II. call(String... arg) to call(String[] arg)

without causing a compiler error in the calling code.

  • A. I
  • B. II
  • C. Both I and II
  • D. Neither I nor II


A.

Note

From within a method, an array parameter and a varargs parameter are treated the same.

From the caller, an array parameter is more restrictive.

Both types can receive an array.

Only a varargs parameter is allowed to automatically turn individual parameters into an array.

Statement I is correct and the answer is Option A.




PreviousNext

Related