Consider the following implementation of a search method:

public int search(ArrayList list, int target)
{
for(int i = list.size() - 1; i >=0 ; i--)
{
if(list.get(i) == target)
{
return i;
}
}
return -1;
}
An ArrayList nums, is initialized with the values [1, 2, 4, 3, 4, 5]. What value would be returned from the call search(nums, 4)?



-1


2


4


This search method is written improperly, and will result in an error.


3

Respuesta :

Answer:

-1

Explanation:

i = 5 and target is 4, hence the result will be -1 going to the else statement because its not equal to the target

The correct answer is -1.

What is implementation?

  • execution, application, carrying out, moving through, performance, enactment, and management. fulfillment, fulfilling, discharge, accomplishment, accomplishment, realization, contrivance, prosecution, affecting.
  • Performance is the execution or practice of a plan, a procedure, or any strategy, idea, model, specification, standard, or policy for accomplishing something. As such, performance is the action that must follow any primary thinking for something to transpire.
  • The commission is preparation and putting elements of the system into place. The commission is the decisions made and movements performed throughout the company, with the purpose of meeting goals outlined in the process.

To learn more about implementation, refer to:

https://brainly.com/question/26872062

#SPJ2