A good answer might be:

The filled blanks are seen below.

Avoiding null

In this example, any slot of the array might reference a String so all slots must be visited. To make the output look nice, slots that contain null are handled differently that those that refer to Strings.

String[] strArray = new String[8] ;  // combined statement

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

(Actually, println() will print "null" when given a null reference, so the if statement is not really required. But with some methods things will go horribly wrong if you send them a null.)

QUESTION 7:

Inspect this code:

for (int j=0; j < strArray.length; j++ )
  System.out.println( "The string " + strArray[j] + " is " +
      strArray[j].length() + " characters long." );

Is this program likely to work?