Writing Methods

AP Computer Science A· difficulty 4/5

Refactor <code>if (x > 0) return true; else return false;</code>:

  • A

    return x > 0;

    check_circle
  • B

    if (x) return true;

  • C

    Cannot refactor

  • D

    return x;

Explanation

Just return the boolean expression.

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

Related questions