IntelliJ Java IDE
The moose likes Mock Exam Errata and the fly likes Boone Mock #32 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Mock Exam Errata
Reply Bookmark "Boone Mock #32" Watch "Boone Mock #32" New topic
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
 
Threads others viewed
error in BB mock exam!
Boone mock: Math.
Could you explain me the answers for this
Math Doubt
BB Question 32
developer file tools