strArray[0] = "Good-by" ;

A good answer might be:

This will replace the reference in slot 0 with a reference to a new String, containing the characters "Good-by" .

Searching a List

Each slot of an array of object references works just like an ordinary object reference variable. In the question, strArray[0] starts out with a reference to one String, then is assigned a reference to another. The first String is now garbage. Here is a start of a longer example program:

class SearchTester
{
  public static void main ( String[] args )
  {
    final int theSize = 20 ;

    String[] strArray = new String[ theSize ] ;  

    strArray[0] = "Boston" ;
    strArray[1] = "Albany" ;
    strArray[2] = "Detroit" ;
    strArray[3] = "Phoenix" ;
    strArray[4] = "Peoria" ;
    strArray[6] = "Albany" ;
    strArray[7] = "Houston" ;
    strArray[8] = "Hartford" ;

    // print out only those slots with data
    for (int j=0; j  < strArray.length; j++ )
      if ( strArray[j] != null )
        System.out.println( strArray[j] );
  }
}

Often a program needs to determine if a particular item is contained in an array.

QUESTION 9:

Is "Peoria" in the list?

Click Here after you have answered the question