Answer:

Yes. New lines are inserted into the program to show this:

Parameter Connected to New Data

In the revised program, the findMax() method is used first with one array, and then with the other array. This is possible because the parameter x of the method refers to the current array, whichever one is used in the method call.

class ArrayOps
{
  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 )
        max = x[index] ;
    return max ;
  }
}

class ArrayDemo
{
  public static void main ( String[] args ) 
  {
    ArrayOps operate = new ArrayOps();
    int[] ar1 =  { -20, 19, 1, 5, -1, 27, 19, 5 } ;
    int[] ar2 =  { 2, 4, 1, 2, 6, 3, 6, 9 } ;

    System.out.println("The first  maximum is: " + operate.findMax( ar1 )  );
    
    System.out.println("The second maximum is: " + operate.findMax( ar2 )  );    
  }
}      

The program prints:

C:\>java ArrayDemo
The first maximum is: 27
The second maximum is: 9

QUESTION 7:

  1. Must each array contain the same number of elements?
  2. Must each array be an array of int?