フリー問題

Java SE 11 Developer のフリー問題 4 / 20 問目

問題文

A helper appends text inside one thread and never publishes the buffer it builds. Which of the two mutable sequence classes does the documentation ask the author to reach for, and why?

選択肢

  1. It asks for StringBuilder ahead of StringBuffer, because the class lacking synchronization is faster under most of the implementations for a buffer that one thread builds
  2. It asks for StringBuffer once the text is handed on, because the class that carries a promise of synchronization is the one meant to replace the other buffer in a single thread
  3. It asks for StringBuffer ahead of StringBuilder, because the class that carries a promise of synchronization keeps a smaller internal buffer under most of the implementations
  4. It asks for StringBuilder once StringBuffer has been handed over and measured, because the two classes part company over the operations each one is designed to publish rather than over the promise each one carries

解答・解説を確認するには

正解と解説の確認、回答の記録には無料登録が必要です。登録すると演習モードでフリー問題に回答し、正誤と解説をその場で確認できます。