• 2022-06-07
    下面代码段输出的结果是( )StringBuffer sb = new StringBuffer("huangjianfeng");sb.delete(1,3);System.out.println(sb.toString());
    A: ngjianfeng
    B: hgjianfeng
    C: hngjianfeng
    D: hjianfeng
  • C

    内容

    • 0

      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); }}程序的输出结果是:______

    • 1

      class Test { public static void main(String[] args) { StringBuffer sb = new StringBuffer("jack"); sb.append(true); sb.append('a'); sb.append(97).append(34.0).append(new char[]{'A','B'}); // 链式编程 System.out.println( sb.toString() ); // 输出缓冲区的中文本数据 sb = new StringBuffer("jack"); sb.insert( 2, "java" ); System.out.println( sb.toString() ); } } A: jacktruea9734.0AB jjavaack B: jacktruea9734.0AB jajavack C: jacktrueaa34.0AB jajavack D: jacktruea9734AB jajavack

    • 2

      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

    • 3

      下列程序对字符串进行操作public class Test{public static void main(String[ ] args){StringBuffer sb = new StringBuffer("保护环境");______1______("责任");//追加字符串System.out.println(sb); ______2______(4,"大家的");//插入字符串System.out.println(sb);______3______(4,7);//删除字符串System.out.println(sb);}}

    • 4

      中国大学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);