Difference between revisions of "Your First Java Program Solutions"

From CompSciWiki
Jump to: navigation, search
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
+
# 19
## 16
+
# 16
## 10
+
# 10
 
<li> ...
 
<li> ...
 
<li> ...
 
<li> ...
 
[[Category:Solutions]]
 
[[Category:Solutions]]
 
[[Category:COMP_1010]]
 
[[Category:COMP_1010]]

Revision as of 11:44, 20 March 2007

  1. ...
  2. ...
  3. Escape sequences exist because the characters they represent either cannot be typed on the keyboard, or have no single-character representation.
  4. The results of the casts are (errors indicated where necessary):
    1. 50
    2. 25L (casting does not round, it merely drops the decimal portion)
    3. 55000000000000000L
    4. Error, 1.23e240 is outside the range of float types.
    5. Error, 2500000000L is outside the range of int types
    6. 6.789E7
    7. 600.0
  5. Recall that escape characters such as \\ and \n may look longer than they really are. They are interpreted by the computer as single characters.
    1. 19
    2. 16
    3. 10
  6. ...
  7. ...