• 2022-06-07
    请阅读下面程序public class ExampleStringBuffer{ public static void main (String[] args){ StringBuffer sb = new StringBuffer (“test”); System.out.println(“buffer = ”+sb); System.out.println(“length = ” + sb.length() ); }}程序运行结果中在"length ="后输出的值是()。
    A: 10
    B: 20
    C: 30
    D: 4
  • D

    举一反三

    内容

    • 0

      class Test { public static void main(String[] args) { StringBuffer sb = new StringBuffer("hello world"); sb.delete(6,sb.length()); System.out.println( sb.toString() ); } } A: Hello w B: Hello C: Hello worl

    • 1

      class Test { public static void main(String[] args) { StringBuffer sb = new StringBuffer("hello world"); sb.replace(6, sb.length(), "java"); System.out.println( sb.toString() ); } } 选择正确的运行结果 A: hello javad B: hellojava C: hello java

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

    • 3

      请阅读下面程序 publicclassExampleStringBuffer publicstaticvoidmain(String[]args) StringBuffersb=newStringBuffer("test"); System.out.println("buffer-,"+sb); System.out.println("longth="+sb.1ength()); 程序运行结果中在“length”后输出的值是( )。 A: 10 B: 4 C: 20 D: 30

    • 4

      下面是一段javabean 程序,该程序的运行结果是 ( ) 。public class NullTest{public static void main(String[] args){int M = 0;String str = null;StringBuffer sb = new StringBuffer(“= “);sb.append(str);sb.append(M++);System.out.println(sb.toString());}} A: =null B: =null0 C: =null1 D: =nullM