← Quiz: Java Strings: all 10 questions
Quiz: Java Strings · Question 8 of 10
You need a changeable string that several threads modify at the same time. Which class fits?
You need a changeable string that several threads modify at the same time. Which class fits?
- A.String
- B.StringBuilder
- C.char
- D.StringBuffer
Answer & explanation
Correct answer: StringBuffer
StringBuffer's methods are synchronized, so it is thread-safe; StringBuilder is faster but not thread-safe.
Can you get the rest right without peeking?
Take the timed Quiz: Java Strings quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →