Which two scenarios are NOT safe to replace a StringBuffer object with a StringBuilder object? (Choose two.)
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.
Explanation:
A & B
A) – StringBuilder is available since 1.5.
B) – StringBuilder is not synchronized. Sharing among multiple not safe.
A- StringBuilder is introduced in JDK 1.5
B- StringBuilder’s access is not synchronized so that it is not thread safe.
For those who are taking the Java SE6 test…
These are the ONLY questions you ever need to know. I took test today and scored 96%. Means I got just two questions wrong. During practice I scored 230/236 here and I assumed I can get 70%.
The questions and options are IDENTICALLY the same. Even the options are NOT CHANGING the order randomly. They are given in the exam as listed here.
Good luck