A good answer might be:

Sure.

ZeroAll Method

Here is the program again, this time with a method that zeros all the elements in the parameter array.

// Array Example
//
class ChangeArray
{
  void print ( int[] x )
  {
    for ( int j=0; j < x.length; j++ )
      System.out.print( x[j] + " " );
    System.out.println( );
  }

  void zeroElt ( int[] x, int elt )
  {
    if ( elt < x.length )
      x[ elt ] = 0; 
  }

  // Make all the elements zero.
  void zeroAll ( int[] ar )
  {

      // stuff goes here

  }
}

class ChangeTest
{
  public static void main ( String[] args )
  {
    ChangeArray cng = new ChangeArray();
    int[] value = {27, 19, 34, 5, 12} ;
    System.out.println( "Before:" );
    cng.print( value );
    
    cng.zeroAll( value  );
    System.out.println( "After:" );
    cng.print( value );
  }
}

QUESTION 10:

Think of what statements should go into the method so that it zeros all elements.