以下要输出“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);
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);
B
举一反三
- 下列代码片段执行结果是: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
- 下面的哪些程序片断可能导致错误?( ) A: String s=”Hello”; String t=,,World"; String k=s+t; B: String s=,,Hello";String t;t=s[3]+"one"; C: String s="Hello,,;String standard = s.tollpperCase(); D: String s="Hello World”;String t=s-”World”;
- 设String对象s= "Hello",运行语句System.out.println(s.concat(" World!"));后String对象s的内容为
- 给定一个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;
- 一个函数为public static void add(String s){},如果想调用该方法,下列正确的是 A: add(String s); B: add(1); C: add(“hello”); D: String s=”world”; add(s);
内容
- 0
设String对象s="H",运行语句System.out.println(s.concat("ello!"));后String对象s的内容为"Hello!",所以语句输出为"Hello!"。
- 1
以下程序的输出结果是 String s1="1",s2="2"; String s=s1+s2; System.out.println(s);
- 2
下列选项中,()是正确的JSP表达式。 A: <;% String s="hello world";%>; B: <;%=hello world";>; C: <;%="hello world"%>; D: <;%!"hello world"%>;
- 3
8、下列选项中,()是正确的表达式。 A: <;% String s="hello world"; %>; B: <;%="hello world"; %>; C: <;% ="hello world" %>; D: <;%! "hello world" %>;
- 4
若String s = “Hello” ; String t = “Hello”;String c=new String(s);则下列哪个表达式返回false?( ) A: s.equals(t); B: t.equals(c); C: s==c; D: s==t;