In Barry Boone's mock exam: Question 32: Given this code snippet: double a = 14.9; double b = method(a); System.out.println(b);
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
His answer is: Question 32: a. Only ceil() & Round() will produce 15.0 from 14.9. The floor() method yields 14. (See chapter 10.) In fact, Math.round() returns long type, so it will produce 15, but not 15.0. I wrote a programme to check it. I think I am right.
Daniel, Both Math.round() and Math.ceil() will result in an output of 15.0 so only answer 'a' is correct. Answer 'c' say only ceil() will result in 15.0 Hope that helps. ------------------ Jane Griscti Sun Certified Programmer for the Java� 2 Platform