网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

定义有StringBuffer s1=new StringBuffer(10);s1.append(“1234”)则s1.length()和s1.capacity()分别是多少?

  • A、4;10
  • B、4;4
  • C、10;10
  • D、10;4

参考答案

更多 “定义有StringBuffer s1=new StringBuffer(10);s1.append(“1234”)则s1.length()和s1.capacity()分别是多少?A、4;10B、4;4C、10;10D、10;4” 相关考题
考题 下面是一段javabean程序,该程序的运行结果是(62)。 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.=nullB.=null0C.=null1D.=nullM

考题 ( 20 )请阅读下面程序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 ) 10B ) 4C ) 20D ) 30

考题 请阅读下面程序 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.10B.4C.20D.30

考题 在Java中,字符串由java.lang.String和( )定义。A.java.lang.StringCharB.java.lang.StringBufferC.java.io.StringCharD.java.io.StringBuffer

考题 下面的程序段执行后,输出的结果是以下哪个选项( )。StringBuffer buf=new StringBuffer("Beijing2008");buf.insert(7,"@");System.out.println(buf.toString()); A、Beijing@2008B、@Beijing2008C、Beijing2008@D、Beijing#2008

考题 下列程序段: String s1=new String("How"); String s2=new String("How"); System.out.println(!(s1==s2)); 的结果为A.falseB.trueC.1D.0

考题 阅读下面程序 public class OperatorsAndExpressions { void equalsMethodl(){ String s1=new String("how are you"); String s2=new String("how are you"); System.out.println(s1==s2); } public static void main(String args[]){ OperatorsAndExpressions perAndExp=new OperatorsAndExpressions(); OperAndExp.equalsMethod1(); } } 程序运行结果是( )。A. ==B.trueC.假D.equal

考题 下列语句输出结果为( )。 public class test { public static void main(StringArgsl[]) { String s1=new String("How"); String s2=new String("How"); System.out.println(!(s1==s2)); } }A.falseB.trueC.1D.0

考题 下列语句输出结果为( )。public class test{public static void main(String args []){String s1=new String("How");String s2=new String("How");System.out.println(!(s1 ==s2));}A.falseB.trueC.1D.0

考题 关于以下代码段的说法中正确的是( )。 (1)String s="abcde"; (2)StringBuffer s1=new StringBuffer("abcde"); (3)if(s.equals(s1)) (4)s1=null; (5)if(sequals(s)) (6)s=null:A.第(1)行编译错误,String 的构造器必须明确调用B.第(3)行编译错误,因为s与s1有不同的类型C.编译成功,但执行时在第(5)行有异常抛出D.编译成功,执行过程中也没有异常抛出

考题 String和StringBuffer类有什么区别

考题 设StringBuffer s=new StringBuffer("Sunday"),那么s.capacity( )的值为6

考题 下面哪些语句是没有编译错误的()A、StringBuffer sb=“java”;B、inti=0x56;C、Boolean b=new Boolean(“java”);D、float f=1.0;

考题 字符串的append函数可以添加多种内容,以下append函数的使用中,错误的是() StringBuffer strb1 = new StringBuffer();  Integer intObj = new Integer(33);A、strb1.append(3.14159);B、strb1.append(’数’);C、strb1.append(true);D、strb1.append(intObj);

考题 public class TestString3 {  public static void main(String[] args) {  // insert code here  System.out.println(s);  }  }  Which two code fragments, inserted independently at line 3, generate the output 4247?()A、 String s = “123456789”; s = (s-”123”).replace(1,3,”24”) - “89”;B、 StringBuffer s = new StringBuffer(”123456789”); s.delete(0,3).replace( 1,3, “24”).delete(4,6);C、 StringBuffer s = new StringBuffer(”123456789”); s.substring(3,6).delete( 1 ,3).insert(1, “24”);D、 StringBuilder s = new StringBuilder(”123456789”); s.substring(3,6).delete( 1 ,2).insert( 1, “24”);E、 StringBuilder s = new StringBuilder(”123456789”); s.delete(0,3).delete( 1 ,3).delete(2,5).insert( 1, “24”);

考题 Public class test (  Public static void stringReplace (String text)  (  Text = text.replace (‘j’ , ‘i’);  )  public static void bufferReplace (StringBuffer text)  (  text = text.append (“C”)  )   public static void main (String args[]}  (  String textString = new String (“java”);  StringBuffer text BufferString = new StringBuffer (“java”);  stringReplace (textString);  BufferReplace (textBuffer);  System.out.printLn (textString + textBuffer);  )  )   What is the output?()

考题 使用String s1=new String("Java");String s2=new String("Java")创建两个字符串时,s1,s2使用不同的内存空间

考题 在lava语言中,定义有两个字符串类,其类名分别为()和StringBuffer。

考题 Given this method in a class:  public String toString() {  StringBuffer buffer = new StringBuffer();  buffer.append(‟‟);  buffer.append(this.name);  buffer.append(‟‟);  return buffer.toString();  }  Which is true?() A、 This code is NOT thread-safe.B、 The programmer can replace StringBuffer with StringBuilder with no other changes.C、 This code will perform well and converting the code to use StringBuilder will not enhance the performance.D、 This code will perform poorly. For better performance, the code should be rewritten: return ““+ this.name + “”;

考题 public class SyncTest{   public static void main(String args) {    final StringBuffer s1= new StringBuffer();    final StringBuffer s2= new StringBuffer();    new Thread () {    public void run() {   synchronized(s1) {   s2.append(“A”);   synchronized(s2) {    s2.append(“B”);    System.out.print(s1);    System.out.print(s2);   }   }    }    }.start();   new Thread() {   public void run() {   synchronized(s2) {  s2.append(“C”);  synchronized(s1) {   s1.append(“D”);  System.out.print(s2);  System.out.print(s1);   }   }    }   }.start();   }   }   Which two statements are true? ()A、 The program prints “ABBCAD”B、 The program prints “CDDACB”C、 The program prints “ADCBADBC”D、 The output is a non-deterministic point because of a possible deadlock condition.E、 The output is dependent on the threading model of the system the program is running on.

考题 以下语句的含义是() char[] arrcrlf={13,10};  String crlf=new String(arrcrlf);  stringBuffer dest = new StringBuffer("西行漫记");  dest.append(crlf); A、字符串"西行漫记"不变B、字符串"西行漫记"的最后一个字被删除C、语句存在语法错误D、在字符串"西行漫记"的后面加回车换行符

考题 填空题在lava语言中,定义有两个字符串类,其类名分别为()和StringBuffer。

考题 单选题以下语句的含义是() char[] arrcrlf={13,10};  String crlf=new String(arrcrlf);  stringBuffer dest = new StringBuffer("西行漫记");  dest.append(crlf);A 字符串西行漫记不变B 字符串西行漫记的最后一个字被删除C 语句存在语法错误D 在字符串西行漫记的后面加回车换行符

考题 单选题Given this method in a class:  public String toString() {  StringBuffer buffer = new StringBuffer();  buffer.append(‟‟);  return buffer.toString();  }  Which is true?()A  This code is NOT thread-safe.B  The programmer can replace StringBuffer with StringBuilder with no other changes.C  This code will perform well and converting the code to use StringBuilder will not enhance the performance.D  This code will perform poorly. For better performance, the code should be rewritten: return ““+ this.name + “”;

考题 填空题Public class test (    Public static void stringReplace (String text) (    Text = text.replace („j„ , „i„);    )      public static void bufferReplace (StringBuffer text) (    text = text.append (“C”)   )      public static void main (String args ){  String textString = new String (“java”);    StringBuffer text BufferString = new StringBuffer (“java”);      stringReplace (textString);    BufferReplace (textBuffer);      System.out.printIn (textString + textBuffer);    }   )   What is the output?()

考题 判断题设StringBuffer s=new StringBuffer("Sunday"),那么s.capacity( )的值为6A 对B 错

考题 多选题public class SyncTest{   public static void main(String args) {    final StringBuffer s1= new StringBuffer();    final StringBuffer s2= new StringBuffer();    new Thread () {    public void run() {   synchronized(s1) {   s2.append(“A”);   synchronized(s2) {    s2.append(“B”);    System.out.print(s1);    System.out.print(s2);   }   }    }    }.start();   new Thread() {   public void run() {   synchronized(s2) {  s2.append(“C”);  synchronized(s1) {   s1.append(“D”);  System.out.print(s2);  System.out.print(s1);   }   }    }   }.start();   }   }   Which two statements are true? ()AThe program prints “ABBCAD”BThe program prints “CDDACB”CThe program prints “ADCBADBC”DThe output is a non-deterministic point because of a possible deadlock condition.EThe output is dependent on the threading model of the system the program is running on.