Dont understand quiz answer for conditional operator

if (5 > 6) {
System.out.println(“C. Senor”);
} else if (6 < 5) {
System.out.println(“Sue Yu”);
} else {
System.out.println(“Jim Sox”);
}

What will the following code print?

  1. Sue Yu
  2. Blank Line
  3. Senor
  4. Jim Sox

Answer is Jim Sox

I dont understand why number 4 though, can someone please help to explain? Quiz did not give any explanation either :frowning:

1 Like

5 > 6 is false so that print statement isn’t used
6 < 5 is false so that print statement isn’t used
The only thing left is the else statement with its print statement.

3 Likes

omg thank you, didnt see it that way… now its just obvious :rofl:

1 Like