Answer:

    str = new String( "You know my methods, Watson.!" );

Objects are Created at Run Time

Before the program runs, there is no object. The new String object is created as the program runs.

class StringDemo1
{
  public static void main ( String[] args )
  {
    String str;

    str = new String( "Elementary, my dear Watson!" );

  }
}

The declaration String str creates a reference variable, but does not create a String. The variable str can be used to refer to a String when one is created.

The next statement is an assignment statement that creates an object and puts a reference to the object in str.

After the program stops running, the String object no longer exists. Its memory is reclaimed by the computer system for other uses.

QUESTION 5:

(Review: ) What are the two steps in an assignment statement?