中国大学MOOC: 有以下代码:String s1 = Hello;String s2 = Hello;String s3 = Hellp;s3 = s3.replace(p, o);这里的s.replace(p, o)的功能是把所有的p都替换成o。以下哪句是正确的?
举一反三
- 有以下代码:String s1 = "Hello";String s2 = "Hello";String s3 = "Hellp";s3 = s3.replace('p', 'o');这里的s.replace('p', 'o')的功能是把所有的'p'都替换成'o'。以下哪句是正确的? A: s1 == s2 是 true, s1 == s3 是 false B: s1 == s2 是 true, s1 == s3 是 true C: s1 == s2 是 false, s1 == s3 是 false D: s1 == s2 是 false, s1 == s3 是 true
- 下面这些代码的功能是创建一个string对象 s,并将其内容设置为字符串 alohaworld ,正确的有: A: string s{'alohaworld'}; B: string s = string{"alohaworld"}; C: char* p = "alohaworld";string s(p); D: string s{'a','l','o','h','a','w','o','r','l','d'}; E: string s('a','l','o','h','a','w','o','r','l','d');
- 以下代码共创建了几个对象?String s1=new String("hello");String s2=new String("hello");String s3=s1;String s4=s2; A: 2 B: 4 C: 1 D: 3
- 以下要输出“hello,world!”正确的是? A: String s=String.format("%1s%2s","hello","world");System.out.println(s); B: String s=String.format("%1$s,%2$s","hello","world");System.out.println(s); C: String s=String.format("%s,%s","hello","world");System.out.println(s); D: String s=String.format("%1s,%2s","hello","world");System.out.println(s);
- 59 给定以下代码,哪些语句的结果不为 true String s1 = “hello” ; String s2 = “hello” ; String s3 = new String(“hello”) ; char[] c = {‘h’,’e’,’l’,’l’,’o’}; String s4 = new String(c); A: s1.equals(s2) B: s3.equals(s4) C: s1==s2 D: s3==s4