Difference between revisions of "Your First Java Program Solutions"
From CompSciWiki
Line 3: | Line 3: | ||
<li>... | <li>... | ||
<li>Escape sequences exist because the characters they represent either cannot be typed on the keyboard, or have no single-character representation. | <li>Escape sequences exist because the characters they represent either cannot be typed on the keyboard, or have no single-character representation. | ||
− | <li> | + | <li>The results of the casts are (errors indicated where necessary): |
# <code>50</code> | # <code>50</code> | ||
# <code>25L</code> (casting does not round, it merely drops the decimal portion) | # <code>25L</code> (casting does not round, it merely drops the decimal portion) | ||
Line 13: | Line 13: | ||
<li> | <li> | ||
Recall that escape characters such as <code>\\</code> and <code>\n</code> may look longer than they really are. They are interpreted by the computer as single characters. | Recall that escape characters such as <code>\\</code> and <code>\n</code> may look longer than they really are. They are interpreted by the computer as single characters. | ||
− | + | # 19 | |
− | + | # 16 | |
− | + | # 10 | |
<li> ... | <li> ... | ||
<li> ... | <li> ... | ||
[[Category:Solutions]] | [[Category:Solutions]] | ||
[[Category:COMP_1010]] | [[Category:COMP_1010]] |
Revision as of 11:44, 20 March 2007
- ...
- ...
- Escape sequences exist because the characters they represent either cannot be typed on the keyboard, or have no single-character representation.
- The results of the casts are (errors indicated where necessary):
-
50
-
25L
(casting does not round, it merely drops the decimal portion) -
55000000000000000L
- Error,
1.23e240
is outside the range offloat
types. - Error,
2500000000L
is outside the range ofint
types -
6.789E7
-
600.0
-
-
Recall that escape characters such as
\\
and\n
may look longer than they really are. They are interpreted by the computer as single characters.- 19
- 16
- 10
- ...
- ...