A good answer might be:

No. Sometimes strArray[j].length() will ask for the length of a non-existent String.


Complete Runnable Example

Here is the complete program:

class StringArray
{
  public static void main ( String[] args )
  {
    String[] strArray = new String[8] ;  

    strArray[0] = "Hello" ;
    strArray[1] = "World" ;
    strArray[2] = "Greetings" ;
    strArray[3] = "Jupiter" ;
    strArray[ strArray.length-1 ] = "the end" ;

    for (int j=0; j  < strArray.length; j++ )
      if ( strArray[j] != null )
        System.out.println( "Slot " + j + ": " + strArray[j] );
      else
        System.out.println( "Slot " + j + ": " + "empty" );
  }
}

You may wish to copy this program to your editor and run it. First-string programers that run this code will see:

Slot 0: Hello
Slot 1: World
Slot 2: Greetings
Slot 3: Jupiter
Slot 4: empty
Slot 5: empty
Slot 6: empty
Slot 7: the end

QUESTION 8:

What will the following statement do. Assume that it immediately follows the last line of the program:

strArray[0] = "Good-by" ;