Answer:

By scanning through the elements of the array, updating a provisional maximum until the last element is reached.

Find Maximum Method

This is the same algorithm that was used in the previous chapter. Now it will be implemented as a method. Here is a partial definition of the ArrayOps class.

class ArrayOps
{                          // the parameter x refers to the data
  int findMax( int[] x )   // this method is called with.                     
  {
    int max = x[0];

    for ( int index=0; index < x.length; index++ )

      if ( x[index]  )

        max = x[index] ;

    return max ;
  }
}

The ArrayOps class contains a method findMax() that finds the maximum of an array.

The parameter list is of the method is: int[] x

The parameter x means "whatever data is supplied when the method starts to run." This might be different data at different times.

QUESTION 3:

Fill in the blank so that the method is complete.