• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Explain this question........

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please do not post questions from that source on this forum
[ April 17, 2007: Message edited by: Barry Gaunt ]
 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Correct answer E!


Right??

Regards,
cmbhatt
 
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
reply
    Bookmark Topic Watch Topic
  • New Topic