Answer:

A variable of a primitive type contains the actual data, not information on where the data is.

Two Kinds of Variables

An object reference does not contain the actual data, just a way to find it. There are two kinds of variables in Java:

 Characteristics
primitive variableContains the actual data.
reference variableContains information on how to find the object.

Here is the example program again:

class EgString
{

  public static void main ( String[] args )
  {
    String str;
    
    str = new String( "The Gingham Dog" );

    System.out.println( str );
  }
}

When the statement

System.out.println( str );

is executed, the reference in str is used to find the object and get the data to be printed.

QUESTION 7:

Does using str in the above statement change the information in it?