123456789101112131415



Question 1: What is the output of the following?
class LowHighSwap
{
static void doIt( int[] z )
{
int temp = z[ z.length-1 ] ;
z[ z.length-1 ] = z[0] ;
z[0] = temp;
}
}

class TestIt
{
public static void main ( String[] args )
{
int[] myArray = {1, 2, 3, 4, 5} ;

LowHighSwap.doIt( myArray );

for (int j=0; j<myArray.length; j++ )
System.out.print( myArray[j] + " " ) ;
}
}

1. 1 2 3 4 5
2. 5 2 3 4 1
3. 1 2 3 4 1
4. 5 2 3 4 5