179k views
5 votes
What is output by the following code segment? int x = 11; int y = 11; if (x != y ) { System.out.print("one"); } else if (x > y) { System.out.print("two"); } else if (y = x) { System.out.print("four"); } else { System.out.print("five"); }

User Zupo
by
5.1k points

1 Answer

4 votes

The output will be four because y and x are equal and that satisfies the condition for the else if statement that prints out four.

User Ross Ridge
by
4.9k points