• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Explain this question........

 
Daniel Pearl
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please do not post questions from that source on this forum
[ April 17, 2007: Message edited by: Barry Gaunt ]
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct answer E!


Right??

Regards,
cmbhatt
 
megha joshi
Ranch Hand
Posts: 206
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
System.out.println(foo);
foo = (int) Math.ceil(bar);
System.out.println(foo);
foo = (int) Math.floor(bar);
System.out.println(foo);
foo = (int) Math.round(bar);
System.out.println(foo);
}

}

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: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic