O'Reilly logo

Java™ How To Program (Early Objects), Tenth Edition by Harvey Deitel, Paul Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Answers to Self-Review Exercises

2.1

a) left brace ({), right brace (}).

b) if.

c) //.

d) Space characters, newlines and tabs.

e) Keywords.

f) main.

g) System.out.print, System.out.println and System.out.printf.

2.2

a) False. Comments do not cause any action to be performed when the program executes.

They’re used to document programs and improve their readability.

b) True.

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

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

e) False. The operators *, / and % are higher precedence than operators + and -.

2.3

a) int c, thisIsAVariable, q76354, number;

or

int c;int thisIsAVariable;int q76354;int number;

b) System.out.print("Enter an integer: ");

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required