下面这些代码的功能是创建一个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');
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 s=new String(“hello”); String t =new String(“hello”); char c [ ] ={‘h’,’e’,’l’,’l’,’o’}; 下列哪些表达式返回true ?
- String s=new String(“hello”);String t =new String(“hello”);char c [ ] ={‘h’,’e’,’l’,’l’,’o’};下列哪些表达式返回true ? A: s.equals(t); B: t.equals(c); C: s= =t ; D: t.equals (new String(“hello”));
- String s= "hello"; String t = "hello"; char c[] = {’h’,’e’,’l’,’l’,’o’} ; Which return true?() A: s.equals(t); B: t.equals(c); C: s==t; D: t.equals(new String("hello")); E: t==c;
- 给出下列的代码,则以下哪个选项返回true String s = "hello"; String t = "hello"; char c[ ] = {''h'',''e'',''l'',''l'',''o''}; A: s.equals(t); B: t.equals(c); C: s = =t D: t = = c;
- 给出下面的代码String s= "hello";String t = "hello";char c[] = {'h','e','l','l','o'};下列选项里,哪些返回true? [] A: s.equals(t); B: t.equals(c); C: s==t; D: t.equals(new String("hello")); E: t==c;