Multiple choice technology programming languages

What is the value of z? double z = 7 / (3 + 0.5);

  1. 0.5

  2. 2

  3. 2.83333333

  4. 3

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The expression 7 / (3 + 0.5) equals 7 / 3.5, which equals exactly 2.0. The presence of 0.5 in the denominator makes the entire division operation use floating-point arithmetic, so the result is 2.0, not the integer-division result 2.