#
34. What is the return value of “SELECT”.substring(0, 5)?
a. “SELECT”
b. “SELEC”
c. “SELE”
d. “ELECT”
#
35. What is the return value of “SELECT”.substring(4, 4)?
a. an empty string
b. C
c. T
d. E
#
Section 4.4.9 Finding a Character or a Substring in a String
36. To check if a string s contains the prefix “Java”, you may write
a. if (s.startsWith(“Java”)) ...
b. if (s.indexOf(“Java”) == 0) …
c. if (s.substring(0, 4).equals(“Java”)) …
d. if (s.charAt(0) == ‘J’ && s.charAt(1) == ‘a’ && s.charAt(2) == ‘v’ && s.charAt(3) == ‘a’) …
#
37. To check if a string s contains the suffix “Java”, you may write
a. if (s.endsWith(“Java”)) ...
b. if (s.lastIndexOf(“Java”) >= 0) …
c. if (s.substring(s.length() – 4).equals(“Java”)) …
d. if (s.substring(s.length() – 5).equals(“Java”)) …
e. if (s.charAt(s.length() – 4) == ‘J’ && s.charAt(s.length() – 3) == ‘a’ && s.charAt(s.length() – 2) == ‘v’ &&
s.charAt(s.length() – 1) == ‘a’) …
#
Section 4.4.10 Conversions between Strings and Numbers
38. The method parses a string s to an int value.
a. integer.parseInt(s);
b. Integer.parseInt(s);
c. integer.parseInteger(s);
d. Integer.parseInteger(s);
#
39. The method parses a string s to a double value.
a. double.parseDouble(s);
b. Double.parsedouble(s);
c. double.parse(s);
d. Double.parseDouble(s);