Run these math expressions, one at a time, in the Java REPL at the right.

  1. What does 5.0/2 return?

  2. What does (double) 5/2 return?

  3. What about 5/2?

  4. Why do the first two return the same answer and the third returns a different answer?

  5. How about 3+5.0/2+5*2?

  6. Let's change the place of the double. What does 3.0+5/2+5*2 return?

  7. Why did changing the place of the double change the answer?

  8. Now for an explicit cast: what does (int)(3.0 + 5)/(2 + 5 * 2) return?

  9. Why do these last three expressions, which look similar, return different values?