阅读下面的语句块,1. StringBuffer Sb = new Strin...oncat(sb);编译出错的有哪几行
举一反三
- 阅读下面的语句块,1.StringBufferSb=newStringBuffer("abc");2.StringS=newString("abc");3.Sb.append("def");4.S.append("def");5.Sb.insert(1,"ghi");6.S.concat(sb);编译出错的有哪几行 A: 2 B: 3 C: 4 D: 6
- 分析下面的Java程序段,编译运行后的输出结果是( )。public class Test {public void changeString(StringBuffer sb) {sb.append("stringbuffer2");}public static void main(String[] args) {Test a = new Test();StringBuffer sb = new StringBuffer("stringbuffer1");a.changeString(sb);System.out.println("sb = " + sb);}} A: sb = stringbuffer2stringbuffer1 B: sb = stringbuffer1 C: sb = stringbuffer2 D: sb = stringbuffer1stringbuffer2
- StringBuffer sb = new StringBuffer("aynu");sb.insert(1, true);System.out.println(sb); A: trueaynu B: atrueynu C: aynutrue D: 运行不通过
- public class StringBufferTest {public static void main(String[] args) {StringBuffer sb=new StringBuffer("aynu,aynu");sb.deleteCharAt(4);System.out.println(sb);//第1空sb.delete(4, 8);System.out.println(sb);//第2空}}
- public class Example { String str = new String("Java"); StringBuffer sb = new StringBuffer("C#"); public void strcat(String str, StringBuffer sb) { str = str + " study"; sb = sb.append(" exam"); } public static void main(String args[]) { Example ex = new Example(); ex.strcat(ex.str, ex.sb); System.out.println(ex.str); System.out.println(ex.sb); }}程序的输出结果是:______