num = Integer.parseInt( "39" );

A good answer might be:

It takes the character string "39", calculates the int value, and assignes that value to the variable num. The result is the same as doing this:

num  =  39;

Converting to Integers

Here is the line from the program, again:

num  = Integer.parseInt( inData ); // convert inData to int

Assignment statements work in two steps:

  1. Evaluate the expression on the right of the equal sign,
  2. Put the value in whatever variable is on the left.

In this particular statement, the expression on the right evaluates to an int value by using a method call. Then in the second step that value is assigned to the variable. This process is usually called converting the characters to an integer.

Caution: The string inData is not changed at all. It is "converted" only in the sense that an integer value is calculated based on its contents.

QUESTION 16:

Which of the following inputs would be correct input for the program?

Enter an integer:  1492
Enter an integer:  Fourteen ninety two
Enter an integer:  14.92
Enter an integer:  -1492
Enter an integer:  1 4 9 2