多选题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 StringBufferInput

题目
多选题
Which two scenarios are NOT safe to replace a StringBuffer object with a StringBuilder object?()
A

When using versions of Java technology earlier than 5.0.

B

When sharing a StringBuffer among multiple threads.

C

When using the java.io class StringBufferInputStream.

D

When you plan to reuse the StringBuffer to build more than one string.


相似考题
更多“多选题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 StringBufferInput”相关问题
  • 第1题:

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

    正确答案:B,E

  • 第2题:

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

    正确答案:B

  • 第3题:

    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.

    正确答案:D

  • 第4题:

    A developer chooses to avoid using SingleThreadModel but wants to ensure that data is updated in athread-safe manner. Which two can support this design goal?()

    • A、Store the data in a local variable.
    • B、Store the data in an instance variable.
    • C、Store the data in the HttpSession object.
    • D、Store the data in the ServletContext object.
    • E、Store the data in the ServletRequest object.

    正确答案:A,E

  • 第5题:

    A Company.com developer chooses to avoid using SingleThreadModel but wants to ensure that data is updated in a thread-safe manner.  Which two can support this design goal?()

    • A、 Store the data in a local variable.
    • B、 Store the data in an instance variable.
    • C、 Store the data in the HttpSession object.
    • D、 Store the data in the ServletContext object.
    • E、 Store the data in the ServletRequest object.

    正确答案:A,E

  • 第6题:

    You work as an application developer at Contoso.com. You use Microsoft .NET Framework 3.5 and Microsoft ADO.NET to develop an application. The database on the Microsoft SQL Server 2005 database has two tables that are displayed by using two SqlConnection objects in two different GridView controls. You want the tables to be displayed at the same time with the use a single SqlConnection object.   What should you do?()

    • A、 Create a bound connection by using the sp_getbindtoken and the sp_bindsession stored procedures.
    • B、 Enable Multiple Active Result Sets (MARS) in the connection string of the application. 
    • C、 Create an exception handler for the connection-busy exception that is thrown on using a single SqlConnection object.
    • D、 Run the two SqlDataReader objects by using a single SqlCommand object.

    正确答案:B

  • 第7题:

    填空题
    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?()

    正确答案: JAVAJAVA
    解析: 暂无解析

  • 第8题:

    多选题
    A developer chooses to avoid using SingleThreadModel but wants to ensure that data is updated in athread-safe manner. Which two can support this design goal?()
    A

    Store the data in a local variable.

    B

    Store the data in an instance variable.

    C

    Store the data in the HttpSession object.

    D

    Store the data in the ServletContext object.

    E

    Store the data in the ServletRequest object.


    正确答案: B,C
    解析: 暂无解析

  • 第9题:

    单选题
    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 method

    B

     replace StringBuilder with StringBuffer

    C

     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


    正确答案: A
    解析: 暂无解析

  • 第10题:

    多选题
    What two descriptions best define DWDM? ()
    A

    a WDM system that is compatible with EDFA technology

    B

    an optical technology for transmitting up to 16 channels over multiple fiber strands

    C

    an optical technology for transmitting up to 32 channels over multiple fiber strands

    D

    a technology for transmitting multiple optical signals using less sophisticated transceiver designthen CWDM

    E

    a technology for transmitting more closely packed optical signals using more sophisticatedtransceiver designs than CWDM


    正确答案: B,A
    解析: 暂无解析

  • 第11题:

    多选题
    Whichtwo scenarios are NOT safe to replace a StringBuffer object with a StringBuilder object?()
    A

    When using versions of Java technology earlier than 5.0.

    B

    When sharing a StringBuffer among multiple threads.

    C

    When using the java.io class StringBufferInputStream.

    D

    When you plan to reuse the StringBuffer to build more than one string.

    E

    Enitiation of separate design processes to the separation of users


    正确答案: A,B
    解析: 暂无解析

  • 第12题:

    多选题
    Dense Wavelength Division Multiplexing (DWDM) is an important innovation in optical networks.Which two descriptions best define DWDM?()
    A

    optical technology for transmitting up to 32 channels over multiple fiber strands

    B

    optical technology for transmitting up to 16 channels over multiple fiber strands

    C

    a WDM system that is compatible with EDFA technology

    D

    a technology for transmitting more closely packed optical signals using more sophisticated transceiver designs than CWDM .


    正确答案: A,B
    解析: 暂无解析

  • 第13题:

    What two descriptions best define DWDM? ()

    • A、 a WDM system that is compatible with EDFA technology
    • B、 an optical technology for transmitting up to 16 channels over multiple fiber strands
    • C、 an optical technology for transmitting up to 32 channels over multiple fiber strands
    • D、 a technology for transmitting multiple optical signals using less sophisticated transceiver designthen CWDM
    • E、 a technology for transmitting more closely packed optical signals using more sophisticatedtransceiver designs than CWDM

    正确答案:A,E

  • 第14题:

    public class Team extends java.util.LinkedList {  public void addPlayer(Player p) {  add(p);  }  public void compete(Team opponent) { /* more code here */ }  }  class Player { /* more code here */ }  Which two are true?()

    • A、 This code will compile.
    • B、 This code demonstrates proper design of an is-a relationship.
    • C、 This code demonstrates proper design of a has-a relationship.
    • D、 A Java programmer using the Team class could remove Player objects from a Team object.

    正确答案:A,D

  • 第15题:

    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?()


    正确答案:javajavaC

  • 第16题:

    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 method
    • B、 replace StringBuilder with StringBuffer
    • C、 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

    正确答案:A

  • 第17题:

    Which two scenarios are NOT safe to replace a StringBuffer object with a StringBuilder object?()

    • A、When using versions of Java technology earlier than 5.0.
    • B、When sharing a StringBuffer among multiple threads.
    • C、When using the java.io class StringBufferInputStream.
    • D、When you plan to reuse the StringBuffer to build more than one string.

    正确答案:A,B

  • 第18题:

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


    正确答案: B
    解析: 暂无解析

  • 第19题:

    多选题
    public class Team extends java.util.LinkedList {  public void addPlayer(Player p) {  add(p);  }  public void compete(Team opponent) { /* more code here */ }  }  class Player { /* more code here */ }  Which two are true?()
    A

    This code will compile.

    B

    This code demonstrates proper design of an is-a relationship.

    C

    This code demonstrates proper design of a has-a relationship.

    D

    A Java programmer using the Team class could remove Player objects from a Team object.


    正确答案: A,D
    解析: 暂无解析

  • 第20题:

    多选题
    Which two statements are true about the hashCode method?()
    A

    The hashCode method for a given class can be used to test for object equality and object inequality for that class.

    B

    The hashCode method is used by the java.util.SortedSet collection class to order theelements within that set.

    C

    The hashCode method for a given class can be used to test for object inequality, but NOT object equality, for that class.

    D

    The only important characteristic of the values returned by a hashCode method is that the distribution of values must follow a Gaussian distribution.

    E

    The hashCode method is used by the java.util.HashSet collection class to group the elements within that set into hash buckets for swift retrieval.


    正确答案: B,E
    解析: 暂无解析

  • 第21题:

    多选题
    Which two scenarios are NOT safe to replace a StringBuffer object with a StringBuilder object?()
    A

    When using versions of Java technology earlier than 5.0.

    B

    When sharing a StringBuffer among multiple threads.

    C

    When using the java.io class StringBufferInputStream.

    D

    When you plan to reuse the StringBuffer to build more than one string.


    正确答案: A,B
    解析: 暂无解析

  • 第22题:

    多选题
    A Company.com developer chooses to avoid using SingleThreadModel but wants to ensure that data is updated in a thread-safe manner.  Which two can support this design goal?()
    A

    Store the data in a local variable.

    B

    Store the data in an instance variable.

    C

    Store the data in the HttpSession object.

    D

    Store the data in the ServletContext object.

    E

    Store the data in the ServletRequest object.


    正确答案: A,C
    解析: 暂无解析

  • 第23题:

    单选题
    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.


    正确答案: D
    解析: 暂无解析

  • 第24题:

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


    正确答案: D,A
    解析: 暂无解析