单选题Given: 22.StringBuilder sb1 = new StringBuilder("123"); 23.String s1 = "123"; 24.// insert code here 25.System.out.println(sb1 + " " + s1); Which code fragment, inserted at line 24, outputs "123abc 123abc"?()Asb1.append(abc); s1.append(abc);Bsb1.append(abc); s1.concat(abc);Csb1.concat(abc); s1.append(abc);Dsb1.concat(abc); s1.concat(abc);Esb1.append(abc); s1 = s1.concat(abc);

单选题
Given: 22.StringBuilder sb1 = new StringBuilder("123"); 23.String s1 = "123"; 24.// insert code here 25.System.out.println(sb1 + " " + s1); Which code fragment, inserted at line 24, outputs "123abc 123abc"?()
A

sb1.append(abc); s1.append(abc);

B

sb1.append(abc); s1.concat(abc);

C

sb1.concat(abc); s1.append(abc);

D

sb1.concat(abc); s1.concat(abc);

E

sb1.append(abc); s1 = s1.concat(abc);


参考解析

解析: 暂无解析

相关考题:

Chinese married couple () red packets to children and the unmarried during the Chinese new Year. A.giveB.have been givingC.are givingD.have given

If a new key 67 is inserted into the given hash table,what will be its address?A.3B.4C.5D.6

Kevin had learnt something._____,he had given men new pride. A.HoweverB.NeverthelessC.MoreoverD.Although

Given:Which code, inserted at line 4, guarantees that this program will output [1, 2]()? A.Set set = new TreeSet();B.Set set = new HashSet();C.Set set = new SortedSet();D.List set = new SortedList();E.Set set = new LinkedHashSet();

Given that the current directory is empty, and that the user has read and write privileges to the current, and the following:Which statement is true?() A.Compilation fails.B.Nothing is added to the file system.C.Only a new file is created on the file system.D.Only a new directory is created on the file system.E.Both a new file and a new directory are created on the file system.

Given the community: community transit-peers members "^(123|456):[3579].0?$"; Which threecommunities does this expression match? () A. 456:91B. 123:70C. 123:440D. 456:321E. 123:550

Given:andtwoseparatecommandlineinvocations:javaYippeejavaYippee1234Whatistheresult?() A.Nooutputisproduced.123B.Nooutputisproduced.234C.Nooutputisproduced.1234D.Anexceptionisthrownatruntime.123

It was said that the new car__________to the institute as a gift by a businessman.A.had givenB.would giveC.had been givenD.has been given

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”);

Given:  Integer i = new Integer (42);  Long l = new Long (42);  Double d = new Double (42.0);   Which two expression evaluate to true?()A、 (i = = l)B、 (i = = d)C、 (d = = l)D、 (i.equals(d))E、 (i.equals(i))F、 (i.equals(42))

下面这段代码的运行结果是()。 Dim MyStringBuilder As New StringBuilder("Hello World!") MyStringBuilder.Replace("!"c, "?"c) Console.WriteLine(MyStringBuilder)A、HelloWorld?cB、HelloWorld?C、HelloWorld!cD、HelloWorld!

String/StringBuilder的异同

关于String,StringBuilder以及StringBuffer,描述错误的是()。A、对String对象的任何改变都不影响到原对象,相关的任何change操作都会生成新的对象B、StringBuffer是线程安全C、StringBuilder是线程安全D、可以修改StringBuilder和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 MyLogger {  private StringBuilder logger = new StringBuuilder();  public void log(String message, String user) {  logger.append(message);  logger.append(user);  }  }  The programmer must guarantee that a single MyLogger object works properly for a multi-threaded system. How must this code be changed to be thread-safe?() A、 synchronize the log methodB、 replace StringBuilder with StringBufferC、 No change is necessary, the current MyLogger code is already thread-safe.D、 replace StringBuilder with just a String object and use the string concatenation (+=) within the log method

Given the community: community transit-peers members "^(123|456):[3579].0?$"; Which threecommunities does this expression match? ()A、456:91B、123:70C、123:440D、456:321E、123:550

单选题Given: What is the result?()A 1B 12C 14D 123

多选题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”);

单选题public class MyLogger {  private StringBuilder logger = new StringBuuilder();  public void log(String message, String user) {  logger.append(message);  logger.append(user);  }  }  The programmer must guarantee that a single MyLogger object works properly for a multi-threaded system. How must this code be changed to be thread-safe?()A synchronize the log methodB replace StringBuilder with StringBufferC No change is necessary, the current MyLogger code is already thread-safe.D replace StringBuilder with just a String object and use the string concatenation (+=) within the log method

单选题下面这段代码的运行结果是()。 Dim MyStringBuilder As New StringBuilder("Hello World!") MyStringBuilder.Replace("!"c, "?"c) Console.WriteLine(MyStringBuilder)AHelloWorld?cBHelloWorld?CHelloWorld!cDHelloWorld!

多选题Given the community: community transit-peers members "^(123|456):[3579].0?$"; Which threecommunities does this expression match? ()A456:91B123:70C123:440D456:321E123:550

单选题Given: Which code, inserted at line 15, creates an instance of the Point class defined in Line?()A Point p = new Point();B Line.Point p = new Line.Point();C The Point class cannot be instatiated at line 15.D Line l = new Line() ; l.Point p = new l.Point();

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

单选题下面这段代码的运行结果是()。 Dim MyStringBuilder As New StringBuilder("Hello World!") MyStringBuilder.Remove(5, 7) Console.WriteLine(MyStringBuilder)AHello_BHelloC_World!DWorld!

多选题1. public class Test {  2. public  T findLarger(T x, T y) {  3. if(x.compareTo(y)  0) {  4. return x;  5. } else {  6. return y;  7. }  8. }  9. }  and:  22. Test t = new Test();  23. // insert code here  Which two will compile without errors when inserted at line 23?()AObject x = t.findLarger(123, “456”);Bint x = t.findLarger(123, new Double(456));Cint x = t.findLarger(123, new Integer(456));Dint x = (int) t.findLarger(new Double(123), new Double(456));

问答题String/StringBuilder的异同

单选题The company should establish procedures to ensure that()related to safety and protection of the environment are given proper familiarization with their duties.Instructions which are essential to be provided prior to sailing should be identified,documented and given.ANew personnelBPersonnel transferred to new assignmentsCAll crewmembersDNew personnel and Personnel transferred to new assignments