フリー問題

Java SE 17 Developer のフリー問題 19 / 20 問目

問題文

A detailed message is assembled by joining several values, and in production the logger discards records at that level. How can the cost of assembling the text be avoided?

選択肢

  1. Ask the logger whether that level would be recorded before assembling, or hand over a supplier that assembles the text on demand
  2. Set the handler of the logger to a lower level, because the handler decides whether the caller assembles the text at all
  3. Keep the assembled message in a field of the class and log that field, because a field is evaluated once while the class is initialized
  4. Lower the level of the logger while the program is running, because the text is assembled by the handler instead of by the code that calls the logger

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

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