下列定义字符串类string对象的语句中,错误的是( )。
A: string str;
B: string str( “Hello, world” );
C: string str = “Hello, world”;
D: string str = ‘Hello, world’;
A: string str;
B: string str( “Hello, world” );
C: string str = “Hello, world”;
D: string str = ‘Hello, world’;
举一反三
- 11字符串测试1:下列字符串定义正确的是: A: String str="Hello World!"; B: Str str="Hello World!"; C: var str="Hello World!"; D: var str='Hello World!';
- 给定一个java程序的代码片断如下,运行后正确的输出结果是( )。String s=”hello, world”;String str = s.replace(“,” , ” ”);System.out.println(str); A: hello world; B: hello, world C: HELLO WORLD D: HELLO ,WORLD;
- 以下语句执行结果是()String str = " hello World ";System.out.println(str.trim()); A: hello World B: hello World C: helloWorld D: 程序异常
- 下列代码执行结果是?( ) class HelloWorld { public static void modifyString(final String str) { str = "Hello World!"; } public static void main(String[] args) { String a = new String("Hello Java"); modifyString(a); System.out.println(“a = ” + a); } } A: a = Hello Java B: a = Hello World C: 代码编译错误 D: 运行时异常
- 有如下代码:public class Test{ public static void main(String args[]) { String str = new String("World"); char ch[] = {'H','e','l','l','o'}; change(str,ch); System.out.println(str + "and" + ch); } public static void change(String str, char ch[]) { str = "Changed"; ch[0] = ' C'; }}运行后输出的结果是: A: Changed and Cello B: World and Cello C: World and CelloChanged and Hello D: World and Hello