Java Reference
In-Depth Information
28. abc\ndef
29. HELLO TONY
30.
The output is
2 + 2 = 4
2 + 2 = 22
In the expression "2 + 2 = " + (2 + 2) the integers 2 and 2 in (2 + 2) are
added to obtain the integer 4 . When 4 is connected to the string "2 + 2" with a
plus sign, the integer 4 is converted to the string "4" and the result is the string
"2 + 2 = 4" . However "2 + 2 = " + 2 + 2 is interpreted by Java to mean
("2 + 2 = " + 2) + 2
The first integer 2 is changed to the string "2" because it is being combined with
the string "2 + 2" . The result is the string "2 + 2 = 2" . The last integer 2 is
combined with the string "2 + 2 = 2" . So, the last 2 is converted to the string
"2" . So the final result is
"2 + 2 = 2" + "2"
which is "2 + 2 = 22" .
31. sam.increaseAge(10);
32. The two kinds of comments are // comments and /* */ comments. Everything
following a // on the same line is a comment. Everything between a /* and a
matching */ is a comment.
33. Hello
Student
34. The normal spelling convention is to spell named constants using all uppercase
letters with the underscore symbol used to separate words.
35. public static final int ANSWER = 42;
Programming Projects
Many of these Programming Projects can be solved using AW's CodeMate.
To access these please go to: www.aw-bc.com/codemate .
1.
One way to measure the amount of energy that is expended during exercise is to
use metabolic equivalents (MET). Here are some METS for various activities:
Running 6 MPH:
10 METS
Basketball:
8 METS
Sleeping:
1 MET
Search WWH ::




Custom Search