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 | 5 | h.length() |
2 | ello | h.substring(1) |
3 | HELLO | h.toUpperCase() |
4 | hello | h.toUpperCase().toLowerCase() |
5 | 0 | h.indexOf("H") |
6 | false | h.startsWith("ell") |
7 | 1 | "Tomorrow".indexOf("o") |
8 | 3 | "Tomorrow".indexOf("o", 3) |
9 | 6 | "Tomorrow".lastIndexOf('o') |
10 | mo | "Tomorrow".substring(2,4) |
11 | 3abc | a.length() + a |
12 | a = "abc" | "a = \"" + a + "\"" |
13 | false | (a.length() + a).startsWith("a") |
14 | illegal | a.length() + a.startsWith("a") |
15 | ">>>3true" | ">>>" + a.length() + a.startsWith("a") |
16 | true | a.substring(1,3).equals("bc") |
17 | false | a.substring(1,3) == "bc" |
18 | < 0 | "a".compareTo("c") |
19 | > 0 | "a".compareTo("A") |
20 | w | s.trim().charAt(2) |