Question: D ecisions in Java Comparing Strings WS 1. For each of the following pairs of strings, state, with reasons, which string precedes the other. (a)
Decisions in Java Comparing Strings WS
1. For each of the following pairs of strings, state, with reasons, which string precedes the other.
(a) "cat" and "dog" (b) "cat" and "Cathy" (c) "X " and " X"
(d) "cab" and "car" (e) "XX" and "X X" (f) "XY" and "XY " (g) "375" and "84" (h) "" and " "
2. State the value of each expression.
(a) "one".equals("one ")
(b) (b) "two".equals("2")
(c) "Three".equals("Three")
(d) "four".equals("for")
3. State whether the value of the expression is negative, zero, or positive.
(a) "for".compareTo("fore")
(b) "fore".compareTo("force") (c) "force".compareTo("Force") (d) "Force".compareTo("Farce") (e) "Farce".compareTo("Fare") (f) "Fare".compareTo("far")
(g) "far".compareTo("far")
(h) "far".compareTo("far ")
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
