if Statements and Control Flow

AP Computer Science A· difficulty 1/5

Which is valid Java syntax for an if-statement?

  • A

    if x > 0: { ... }

  • B

    if (x > 0) { ... }

    check_circle
  • C

    if (x > 0) then { ... }

  • D

    if x > 0 { ... }

Explanation

Java requires parentheses around the condition.

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

Related questions