关于以下程序段,运行结果是()1.String s1 =“a”+“b”; 2.String s2 = new String(s1); 3.if(s1 == s2)4.Sytstem.out.print("hello")); 5.if (s1.equals(s2)) 6.Sytstem.out.print("world"));
A: hello
B: world
C: helloworld
D: 没有输出
A: hello
B: world
C: helloworld
D: 没有输出
举一反三
- 以下程序的输出结果是 String s1="1",s2="2"; String s=s1+s2; System.out.println(s);
- 关于以下程序段,正确的说法是( ) 1 String s1=”abc”+”def” 2 String s2=new String(s1); 3.If(s1= =s2) 4.System.out.println(“= = succeeded”); 5.if (s1.equals(s2)) 6.System.out.println(“.equals() succeeded”);
- 下列代码片段执行结果是:String s=new String(”abc”); String s1=new String(s); if(s==s1){ System.out.println(”Hello”); } if(s.equals(s1)){ System.out.println(”World”); } A: Hello World B: Hello C: World D: Null
- (10-8)关于以下程序段,正确的说法是( )。 1 String s1=”ac”+”def”; 2 String s2=new String(s1); 3 if(s1.equals(s2)) 4 System.out.println(“equals() succeeded”); 5 else if(s1==s2) 6 System.out.println(“== succeeded”);
- 以下要输出“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);