Expressions and Assignment Statements

AP Computer Science A· difficulty 3/5

int result = 2 + 3 * 4;
System.out.println(result);

What is printed?

  • A

    24

  • B

    20

  • C

    14

    check_circle
  • D

    11

Explanation

Multiplication has higher precedence than addition, so 3 * 4 = 12 is computed first, then 2 + 12 = 14.

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

Related questions

AP Computer Science A · Expressions and Assignment Statements Practice Question | Acemy