This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: 5. Self Check 5.4 Which Comparisons are Syntactically Incorrect? Logically Questionable? Which of the following comparisons are syntactically incorrect? Which of them are syntactically correct, but logically questionable? String a = &quot;1&quot;; String b = &quot;one&quot;; double x = 1; double y = 3 * (1.0 / 3); a. a == 1 b. a == null c. a.equals() d. a == b e. a == x f. x == y g. x - y == null h. x.equals(y) 6. Self Check 5.8 When does the statement System.out.println(x &gt; 0 || x &lt; 0); print false? 7. Self Check 5.9 Rewrite the following expression, avoiding the comparison with false : if (Character.isDigit(ch) == false) . . . 8. Explain the difference between r == s and r.equals(s) when r and s are strings....
View Full Document
- Spring '11