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

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

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


参考答案

更多 “设StringBuffer s=new StringBuffer("Sunday"),那么s.capacity( )的值为6” 相关考题
考题 ( 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

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

考题 String 和StringBuffer的区别

考题 关于以下代码段的说法中正确的是( )。 (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.编译成功,执行过程中也没有异常抛出

考题 字符串的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、StringBuffer 和 StringBuilder 说法错误的是()A、String 创建的字符串是不可变的B、StringBuffer 创建的字符串是可变的,而所引用的地址一直不变C、StringBuffer 是线程安全的,因此性能比 StringBuilder 好D、StringBuilder 没有实现线程安全,因此性能比 StringBuffer 好

考题 关于String和StringBuffer,下面那些是正确的:()A、常量字符串使用String,非常量字符串使用StringBuffer。B、使用StringBuffer的时候设置初始容量。C、尽量使用StringTokenizer代替indexOf()和substring()。D、尽量不要使用StringBuffer,StringTokenizer类。

考题 设原字符串s为StringBuffer型,且s="Hellojava",如果想用子串替换把s转换成"HelloWorld",则正确的语句是()A、s.replace(6,9,"World");B、s.replace(6,10,"World");C、s="World";D、s=replace("java","World");

考题 String类和StringBuffer类的区别是什么?StringBuffer类提供了哪些独特的方法?

考题 定义有StringBuffer s1=new StringBuffer(10);s1.append(“1234”)则s1.length()和s1.capacity()分别是多少?A、4;10B、4;4C、10;10D、10;4

考题 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 + “”;

考题 Which methods from the String and StringBuffer classes modify the object on which they are called?()  A、The charAt() method of the String class.B、The toUpperCase() method of the String class.C、The replace() method of the String class.D、The reverse() method of the StringBuffer class.E、The length() method of the StringBuffer class.

考题 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、在字符串"西行漫记"的后面加回车换行符

考题 多选题关于String和StringBuffer,下面那些是正确的:()A常量字符串使用String,非常量字符串使用StringBuffer。B使用StringBuffer的时候设置初始容量。C尽量使用StringTokenizer代替indexOf()和substring()。D尽量不要使用StringBuffer,StringTokenizer类。

考题 多选题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?()AString s = “123456789”; s = (s-”123”).replace(1,3,”24”) - “89”;BStringBuffer s = new StringBuffer(”123456789”); s.delete(0,3).replace( 1,3, “24”).delete(4,6);CStringBuffer s = new StringBuffer(”123456789”); s.substring(3,6).delete( 1 ,3).insert(1, “24”);DStringBuilder s = new StringBuilder(”123456789”); s.substring(3,6).delete( 1 ,2).insert( 1, “24”);EStringBuilder s = new StringBuilder(”123456789”); s.delete(0,3).delete( 1 ,3).delete(2,5).insert( 1, “24”);

考题 单选题Which methods from the String and StringBuffer classes modify the object on which they are called?()A The charAt() method of the String class.B The toUpperCase() method of the String class.C The replace() method of the String class.D The reverse() method of the StringBuffer class.E The length() method of the StringBuffer class.

考题 多选题Which two scenarios are NOT safe to replace a StringBuffer object with a StringBuilder object?()AWhen using versions of Java technology earlier than 5.0.BWhen sharing a StringBuffer among multiple threads.CWhen using the java.io class StringBufferInputStream.DWhen you plan to reuse the StringBuffer to build more than one string.

考题 问答题String类和StringBuffer类的区别是什么?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.