| Author |
Boone Mock #32
|
Rolf Weasel
Ranch Hand
Joined: Feb 26, 2000
Posts: 82
|
|
This is with reference to the Boone Mock dated March 5, 2000 located here Question 32: Given this code snippet: If this snippet displays 15.0 in the standard output, what Math method(s) could method() have invoke? Select the one right answer. a. ceil() and round() b. floor() and round() c. ceil() only d. floor() only e. round() only Answer: Question 32: c. Only ceil(). Round() will produce 15 from 14.9 not 15.0. The floor() method yields 14. (See chapter 10.) In the code, the result of method() is assigned to the double b before printing. Hence, the result of round(a) will be promoted to 15.0. The answer should be (a). [This message has been edited by Rolf Weasel (edited March 12, 2000).]
|
May the Moose be with you.
|
 |
Carl Trusiak
Sheriff
Joined: Jun 13, 2000
Posts: 3340
|
|
|
Round does yield an int result however since it is assigned to a double (b), it is automatically cast to a double and the call to System.out.println(b) yields 15.0.
|
I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
|
 |
 |
|
|
subject: Boone Mock #32
|
|
|