A good answer might be:

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

NumberFormatException

If the user enters one of the WRONG lines, the statement inData = stdin.readLine() will work without any problem. It will read in the characters the user typed and put them in the String object inData. However, the method parseInt in the statement num = Integer.parseInt( inData ) will not be able to understand the characters as an integer, and with throw an exception. The user will see something like:

Enter an integer:
14.92
java.lang.NumberFormatException: 14.92

This exception was passed out of the running program to the Java system, which stopped the program and wrote the error message.

The parseInt method is just one method of the wrapper class Integer. It should be used like this:

intVariable = Integer.parseInt( stringVariable );

The stringVariable should contain only characters that can be interpreted as an integer.

QUESTION 17:

Could the following be interpreted as an integer?

"  84"

Notice that there are two spaces preceeding the '8' character.