else if Statements

AP Computer Science A· difficulty 3/5

For grade computation, after <code>if (g >= 90)</code> returns A, the next <code>else if (g >= 80)</code> should have what condition?

  • A

    g == 80

  • B

    g >= 80 && g < 90 (redundant)

  • C

    g >= 80 (suffices because earlier branch caught >= 90)

    check_circle
  • D

    g >= 80 || g < 90

Explanation

Cascading else-if eliminates the need for explicit upper bound.

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

Related questions