Lexicographical Comparison
The program evaluates boolean conditions involving string equality and order to determine the final output.
What is printed when the following Java program is compiled and run?
public class QuestionTrace {
public static void main(String[] args) {
String s1 = "Apple";
String s2 = "Apply";
boolean result = s1.compareTo(s2) < 0 && s1.equals("Apple");
System.out.println(result);
}
}
A
false
B
0
C
true
D
1
Question Leaderboard
Not enough data yet to show leaderboard.
