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 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.

相似考题
参考答案和解析
正确答案:A,B
更多“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 StringBufferInput”相关问题
  • 第1题:

    What two situations could require the use of multiple routing protocols? ()

    • A、when all equipment is manufactured by Cisco
    • B、when there are multiple paths to destination networks
    • C、because having multiple routing protocols confuses hackers
    • D、when migrating from an older Interior Gateway Protocol (IGP) to a new IGP
    • E、when  using UNIX host - based routers
    • F、when smaller broadcast domains are desired

    正确答案:D,E

  • 第2题:

    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

  • 第3题:

    Your web application requires the adding and deleting of many session attributes during a complex usecase. A bug report has come in that indicates that an important session attribute is being deleted too soonand a NullPointerException is being thrown several interactions after the fact. You have decided to create asession event listener that will log when attributes are being deleted so you can track down when theattribute is erroneously being deleted. Which listener class will accomplish this debugging goal?()

    • A、Create an HttpSessionAttributeListener class and implement the attributeDeleted method and log the attribute name using the getName method on the event object.
    • B、Create an HttpSessionAttributeListener class and implement the attributeRemoved method and log the attribute name using the getName method on the event object.
    • C、Create an SessionAttributeListener class and implement the attributeRemoved method and log the attribute name using the getAttributeName method on the event object.
    • D、Create an SessionAttributeListener class and implement the attributeDeleted method and log the attribute name using the getAttributeName method on the event object.

    正确答案:B

  • 第4题:

    Which statements concerning the methods notify() and notifyAll() are true?  

    • A、Instances of class Thread have a method called notify().
    • B、A call to the method notify() will wake the thread that currently owns the monitor of the object.
    • C、The method notify() is synchronized.
    • D、The method notifyAll() is defined in class Thread.
    • E、When there is more than one thread waiting to obtain the monitor of an object, there is no way to be     sure which thread will be notified by the notify() method.

    正确答案:A,E

  • 第5题:

    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

  • 第6题:

    Given a class whose instances, when found in a collection of objects, are sorted by using the compareTo() method, which two statements are true?()

    • A、The class implements java.lang.Comparable.
    • B、The class implements java.util.Comparator.
    • C、The interface used to implement sorting allows this class to define only one sort sequence.
    • D、The interface used to implement sorting allows this class to define many different sort sequences.

    正确答案:A,C

  • 第7题:

    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

  • 第8题:

    In which situation would you use static database registration for a listener()

    • A、when multiple databases are to be registered with the listener
    • B、when DBAs need to connect remotely to start up the database instance
    • C、when users need to connect the database instance using the host naming method
    • D、when the database instance that is to be registered with the listener is configured in shared server mode

    正确答案:B

  • 第9题:

    单选题
    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
    解析: 暂无解析

  • 第10题:

    多选题
    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
    解析: 暂无解析

  • 第11题:

    多选题
    Your web application uses a simple architecture in which servlets handle requests and then forward to aJSP using a request dispatcher. You need to pass information calculated in the servlet to the JSP for view generation.This information must NOT be accessible to any other servlet,JSP or session in the webapp. Which two techniques can you use to accomplish this goal?()
    A

    Add attributes to the session object.

    B

    Add attributes on the request object.

    C

    Add parameters to the request object.

    D

    Use the pageContext object to add request attributes.

    E

    Add parameters to the JSP’s URL when generating the request dispatcher.


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

  • 第12题:

    单选题
    When using the radar for navigating().
    A

    the best fix is obtained by using a tangent bearing and a range

    B

    and using two radar ranges for a fix,the objects of the ranges should be close to reciprocal bearings

    C

    and using ranges,the most rapidly changing range should be measured last

    D

    and crossing a radar range of one object with the visual bearing of a second object,the two objects should be 80°to 110°apart


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

  • 第13题:

    When you are designing a Web application, which options define how rich text displays in a browser?()

    • A、"Using HTML"
    • B、"Using Java Applet"
    • C、"Using AJAX Control"
    • D、"Using Best Fit for OS"

    正确答案:C

  • 第14题:

    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

  • 第15题:

    When multiple PPP over Ethernet subscribers connect using the same DSL modem, which two attributes does the ERX use to differentiate between subscribers? ()(Choose two.)

    • A、PPP session ID
    • B、subscriber name
    • C、source MAC address
    • D、destination MAC address

    正确答案:A,C

  • 第16题:

    Which of the following is eliminated when using SATA instead of PATA technology?()

    • A、Jumper selection
    • B、Power connector
    • C、Data port connector
    • D、Hard drive LEDs

    正确答案:A

  • 第17题:

    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

  • 第18题:

    Your web application uses a simple architecture in which servlets handle requests and then forward to aJSP using a request dispatcher. You need to pass information calculated in the servlet to the JSP for view generation.This information must NOT be accessible to any other servlet,JSP or session in the webapp. Which two techniques can you use to accomplish this goal?()

    • A、Add attributes to the session object.
    • B、Add attributes on the request object.
    • C、Add parameters to the request object.
    • D、Use the pageContext object to add request attributes.
    • E、Add parameters to the JSP’s URL when generating the request dispatcher.

    正确答案:B,E

  • 第19题:

    Which object is added to a form module when you copy the reusable calender class?()

    • A、List icon 
    • B、Object group 
    • C、PL/SQL library 
    • D、Key-Listval trigger 

    正确答案:B

  • 第20题:

    When is an implicit anchor created?()

    • A、When an object is enclosed by another object. 
    • B、When a page break after pagination property is enabled. 
    • C、When a link is created between two objects. 
    • D、When a keep with anchoring object pagination property is enabled.

    正确答案:A

  • 第21题:

    单选题
    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
    解析: 暂无解析

  • 第22题:

    多选题
    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
    解析: 暂无解析

  • 第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
    解析: 暂无解析