Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
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: 1710
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...
I agree. Here's the link:
subject: Explain this question........
It's not a secret anymore!