Question 361
String s1 = "CAT";
String s2 = "CATALOG";
boolean a = s1.compareTo(s2) > 0;
boolean b = s2.substring(0, s1.length()).equals(s1);
boolean c = s1.length() < s2.length();
System.out.println(a + " " + b + " " + c);Main Solution
Solution:
Correct: C. "CAT" is a prefix of "CATALOG": compareTo returns 3 − 7 = −4, so a = false. s2.substring(0,3) = "CAT", equal to s1 → b = true. 3 < 7 → c = true. Output: false true true.
Answer: Correct: C
Answer images

