This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Val mock Q21

 
Kareem Qureshi
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Val
Can you explain the answer in Q21 in more detail, because i feel that getBoolean method can never return true. I think (int)Math.random*2 will always be equal to 0. If u see the javadocs, random()
Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. Returned values are chosen pseudorandomly with (approximately) uniform distribution from that range.
am I missing something here?
Please correct me
thanks in advance
kareem
 
Kareem Qureshi
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry
i figured out where i am wrong because anything greater than .5 will make the expression return value greater than 1
kareem
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic