else if Statements

AP Computer Science A· difficulty 2/5

int score = 75;
if (score >= 90) {
  System.out.println("A");
} else if (score >= 80) {
  System.out.println("B");
} else if (score >= 70) {
  System.out.println("C");
} else {
  System.out.println("F");
}

What is printed?

  • A

    C

    check_circle
  • B

    B

  • C

    F

  • D

    A

Explanation

score is 75. The first two conditions (>=90, >=80) fail. The third (>=70) is true, so "C" is printed and the rest of the chain is skipped.

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

Related questions