フリー問題

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

問題文

A class implements the marker interface for serialization, and one of its fields holds a cached password that must never be written to a file. What has to change?

選択肢

  1. That field has to be declared static, because the state of the class is written into a separate part of the stream that the reader is able to skip
  2. That field has to carry the modifier that excludes it from serialization, so the restored object receives the default value for the declared type of that field
  3. The whole class has to implement the interface for external serialization, because a field is excluded only when the class writes its own fields by hand
  4. That field has to be declared final, because a final field is left out of the stream and rebuilt from the constructor when the object is restored

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

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