A good answer might be:

No. Each j is local to its own method. They are different local variables.

A Method Can't Use Another's Local Variable

Here is the program (yet again!) with a slight mistake. Can you find the mistake?

// 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 )
  {
    for ( j=0; j < ar.length; j++ )
      ar[j] = 0;
  }

}

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 );
  }
}

The mistake is a syntax error. The compiler will find it right away and not compile the program.

QUESTION 12:

Where is the mistake?