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:
|
Converting to IntegersHere is the line from the program, again:
Assignment statements work in two steps:
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? Click Here after you have answered the questionEnter 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 |