Answers to Self-Review Exercises

2.1
  1. left brace ({), right brace (}).

  2. semicolon (;).

  3. if.

  4. //.

  5. Blank lines, space characters, newline characters and tab characters.

  6. Keywords.

  7. main.

  8. System.out.print, System.out.println and System.out.printf.

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

  2. True.

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

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

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

2.3
  1. int c, thisIsAVariable, q76354, number;

    or

    int c;

    int thisIsAVariable;

    int q76354;

    int

Get Java™ How to Program, Seventh Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.