Sunday, April 21, 2013

Java Self-Review Exercise 2


State whether each of the following is true or false. If false, explain why.

1.) Comments cause the computer to print the text after the // on the screen when the program
executes.

2.) All variables must be given a type when they are declared.

3.) Java considers the variables number and NuMbEr to be identical.

4.) False. The remainder operator can also be used with noninteger operands in Java.

5.) The arithmetic operators *, /, %, + and - all have the same level of precedence.

6.) Method Integer.parseInt converts an integer to a String.




Answers:

1.  ANS: False. Comments do not cause any action to be performed when the program is executed.
They are used to document programs and improve their readability.

2.  ANS: True

3.  ANS: False. Java is case sensitive, so these variables are distinct.

4.  ANS: False. The operators *, / and % are on the same level of precedence, and the operators
+ and - are on a lower level of precedence.

5.  ANS: False. The modulus operator can also be used with noninteger operands in Java.

6.  ANS: False. Integer.parseInt method converts a String to an integer (int) value.

No comments:

Post a Comment