Name ______________________
Assume the following:
String s, t, h, a; String n, e; int i; h = "Hello"; s = " How are you? "; a = "abc"; n = null; e = "";
Give the values of the following expressions, or illegal.
| 1 | __________ | h.length() |
| 2 | __________ | h.substring(1) |
| 3 | __________ | h.toUpperCase() |
| 4 | __________ | h.toUpperCase().toLowerCase() |
| 5 | __________ | h.indexOf("H") |
| 6 | __________ | h.startsWith("ell") |
| 7 | __________ | "Tomorrow".indexOf("o") |
| 8 | __________ | "Tomorrow".indexOf("o", 3) |
| 9 | __________ | "Tomorrow".lastIndexOf('o') |
| 10 | __________ | "Tomorrow".substring(2,4) |
| 11 | __________ | a.length() + a |
| 12 | __________ | "a = \"" + a + "\"" |
| 13 | __________ | (a.length() + a).startsWith("a") |
| 14 | __________ | a.length() + a.startsWith("a") |
| 15 | __________ | ">>>" + a.length() + a.startsWith("a") |
| 16 | __________ | a.substring(1,3).equals("bc") |
| 17 | __________ | a.substring(1,3) == "bc" |
| 18 | __________ | "a".compareTo("c") |
| 19 | __________ | "a".compareTo("A") |
| 20 | __________ | s.trim().charAt(2) |