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" .


String[] args

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 the familiar signature of the main() method:

public static void main( String[] args )

The pharse String[] args says that main() has a parameter which is an array of String references. This array is constructed by the Java system just before main() gets control. The elements of the array refer to Strings that contain text from the command line that starts the program. For example, say that a program is started with this command line:

C:\>java StringDemo stringA stringB stringC

The picture shows what the parameter args looks like while main() is running.

QUESTION 9:

What would the following statement print?

System.out.println( args[0] );