Casting and Ranges of Variables

AP Computer Science A· difficulty 4/5

For <code>double d = 5; int x = (int) d / 2;</code>, x equals

  • A

    2

    check_circle
  • B

    2.5

  • C

    Compile error

  • D

    3

Explanation

Cast applies first to d → 5; then 5/2 (int division) = 2.

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

Related questions