Q. Questions 7-8 refer to the following method public void printVals(String[] items, int k) { if(k > 1) { printVals(items, k - 1); System.out.print(items[k] + " "); printVals(items, k - 2); } } Suppose the following code segment has been executed. String[] names = {"Pat", "Joe", "Ann", "Cal", "Amy"}; printVals(names, name.length - 1); 7.What is the output?

Respuesta :

Limosa

Answer:

Ann Cal Amy Ann  is the correct output.

Explanation:

Following are the description for the output.

In the above program of the Java Programming Language, set a public void data type function 'printVals' and pass string type argument 'items' and integer type argument 'k' and inside the it.

  • Set the if conditional statement to check the variable 'k' is greater than 1.
  • Then, print the items of the variable 'k' by adding space in it.
  • Finally, set a string data type array variable that is 'names' and pass the following string values and call the following function.
ACCESS MORE
EDU ACCESS