Expressions and Assignment Statements

AP Computer Science A· difficulty 2/5

What is the value of <code>7 / 2</code> in Java when both operands are <code>int</code>?

  • A

    4

  • B

    3

    check_circle
  • C

    3.5

  • D

    Compiler error

Explanation

Integer division truncates the fractional part: 7/2 = 3.

Want 10 more like this — adaptive to your weak spots?

Related questions