This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Explain this question........ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Explain this question........" Watch "Explain this question........" New topic

Explain this question........

Daniel Pearl

Joined: Apr 13, 2007
Posts: 3
Please do not post questions from that source on this forum
[ April 17, 2007: Message edited by: Barry Gaunt ]
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Correct answer E!



megha joshi
Ranch Hand

Joined: Feb 20, 2007
Posts: 206
Try this

import java.lang.Math.*;
public class Main
public static void main(String[] args)
double bar = -2.7;
int foo;
//int foo = (int) Math.max(3);
// foo = (int) Math.min(2);
foo = (int) Math.abs(bar);
foo = (int) Math.ceil(bar);
foo = (int) Math.floor(bar);
foo = (int) Math.round(bar);


Try substituting 2.7 and try again, try uncommenting the commented out lines and see what's the error message.

Give a thought to the outputs.

The correct answer for your question would be foo = (int) Math.floor(bar);
Tell me why
Hope this helps...
GeeCON Prague 2014
subject: Explain this question........