Multiple choice technology programming languages

What is the value of x? int x = 8 / 3;

  1. 1

  2. 2

  3. 2.66666667

  4. 3

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

When both operands are integers, Java performs integer division which truncates the decimal portion. Therefore 8 / 3 equals 2, not 2.666. The result type matches the operand types (int), so no decimal component is retained.