更多"String[] elements = "的相关试题:
[单项选择] 11. String test = “Test A. Test B. Test C.”; 12. // insert code here 13. String[] result = test.split(regex); Which regular expression inserted at line 12 will correctly split test into “Test A,” “Test B,” and “Test C”?()
A. String regex = “”;
B. String regex = “ “;
C. String regex = “.*“.
D. String regex = “//s”
E. String regex = “//.//s*”;
F. String regex = “//w[ /.] +“;
[单项选择] 11. String test = “This is a test”; 12. String[] tokens = test.split(”/s”); 13. System.out.println(tokens.length); What is the result?()
A. 0
B. 1
C. 4
D. Compilation fails.
E. An exception is thrown at runtime.
[单项选择] String a = “ABCD”; String b = a.toLowerCase(); b.replace(‘a’, ‘d’); b.replace(‘b’, ‘c’); System.out.println(b); What is the result? ()
A. abcd
B. ABCD
C. dccd
D. dcba
E. Compilation fails.
F. An exception is thrown at runtime.
[填空题] 5. String foo = “base”; 6. foo.substring(0,3); 7. foo.concat(“ket”) 8. Type the value of foo at line 8.()
[填空题] 3. string foo = “ABCDE”; 4. foo.substring(3); 5. foo.concat(“XYZ”); 6. Type the value of foo at line 6.()
[多项选择] 35. String #name = “Jane Doe”; 36. int$age=24; 37. Double_height = 123.5; 38. double~temp = 37.5; Which two are true?()
A. Line 35 will not compile.
B. Line 36 will not compile.
C. Line 37 will not compile.
D. Line 38 will not compile.
[单项选择] 12. String csv = “Sue,5,true,3”; 13. Scanner scanner = new Scanner( csv); 14. scanner.useDelimiter(”,”); 15. int age = scanner.nextInt(); What is the result?()
A. Compilation fails.
B. After line 15, the value of age is 5.
C. After line 15, the value of age is 3.
D. An exception is thrown at runtime.
[单项选择] String foo = “blue”; Booleanbar = new Boolean [1]; if (bar[0]) { foo = “green”; } What is the result?()
A. Foo has the value of “”
B. Foo has the value of null.
C. Foo has the value of “blue”
D. Foo has the value of “green”
E. An exception is thrown.
F. The code will not compile.
[单项选择] 11. String test= “a1b2c3”; 12. String[] tokens = test.split(”//d”); 13. for(String s: tokens) System.out.print(s +“ “); What is the result?()
A. a b c
B. 1 2 3
C. a1b2c3
D. a1 b2 c3
E. Compilation fails.
F. The code runs with no output.
G. An exception is thrown at runtime.
[单项选择] 现有代码片段: String s="123"; String sl=S+456; 请问sl的结果是哪项?()
A. 123456
B. 579
C. 编译错误
D. 运行时抛出异常
[单项选择] Given: 11. String test = "This is a test"; 12. String[] tokens = test.split("/s"); 13. System.out.println(tokens.length); What is the result?()
A. An exception is thrown at runtime.
B. 1
C. 4
D. Compilation fails.
E. 0
[单项选择] public String makinStrings() { String s = “Fred”; s = s + “47”; s = s.substring(2, 5); s = s.toUpperCase(); return s.toString(); } How many String objects will be created when this method is invoked?()
A. 1
B. 2
C. 3
D. 4
E. 5
F. 6
[单项选择] public static void test(String str) { int check = 4; if (check = str.length()) { System.out.print(str.charAt(check -= 1) +“, “); } else { System.out.print(str.charAt(0) + “, “); } } and the invocation: test(”four”); test(”tee”); test(”to”); What is the result?()
A. r, t, t,
B. r, e, o,
C. Compilation fails.
D. An exception is thrown at runtime.
[单项选择] class Sock2 { String color; public boolean equals(Object o) { return color.equals(((Sock2)o).color); } } class TestSocks { public static void main(String [] args) { Sock2 s1 = new Sock2(); s1.color = "blue"; Sock2 s2 = new Sock2(); s2.color = "blue"; if (s1.equals(s2)) System.out.print("equals "); if (s1 == s2) System.out.print("== "); } } 结果为:()
A. ==
B. equals
C. equals ==
D. 无结果输出
[多项选择] Given: String value = getServletContext().getInitParameter("foo"); in an HttpServlet and a web applicationdeployment descriptor that contains:
foo frodo Which two are true?()
A. The foo initialization parameter CANNOT be set programmatically.
B. Compilation fails because getInitParameter returns type Object.
C. The foo initialization parameter is NOT a servlet initialization parameter.
D. Compilation fails because ServletContext does NOT have a getInitParameter method.
E. The foo parameter must be defined within the
element of the deployment descriptor.
[单项选择] int index = 1; String [] test = new String[3]; String foo = test[index]; What is the result?()
A. Foo has the value “”
B. Foo has the value null
C. An exception is thrown
D. The code will not compile
[多项选择] class Sock { String size; String color; public boolean equals(Object o) { Sock s = (Sock) o; return color.equals(s.color); } // insert code here } 哪两个满足 hashCode 的约定?()
A. public int hashCode() { return 343; }
B. public int hashCode() { return size.hashCode (); }
C. public int hashCode() { return color.hashCode (); }
D. public int hashCode() { return (int) (Math.random() * 1000);