中国大学MOOC: 运行如下程序,输出结果是()。StringBuffer sb = new StringBuffer(good morning!);String sub = sb.substring(0, 8);System.out.println(sub);System.out.print(/);char c = sb.charAt(6);System.out.println(c);
举一反三
- 运行如下程序,输出结果是()。StringBuffer sb = new StringBuffer("good morning!");String sub = sb.substring(0, 8);System.out.println(sub);System.out.print("/");char c = sb.charAt(6);System.out.println(c); A: good mor/o B: good morn/o C: good morn/m D: good mor/o
- 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); }}程序的输出结果是:______
- 5、下列程序的运行结果是()。public static void main( String[] args ){StringBuffer sb = new StringBuffer();sb.append("qq").append("ww");show( sb, "ss" );System.out.println( sb.length() );}public void show( StringBuffer sb, String str ){sb.append( str );} A: 4 B: 2 C: 6 D: 0
- 分析下面的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: 运行不通过