フリー問題

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

問題文

A cache compares a set it holds against the unmodifiable view of that very set that Collections.unmodifiableCollection returned, and the comparison reports that the two are not equal although every element reads through. What does the Collections class say about the view, and why?

選択肢

  1. The view leans on the equality of the root class, because the class keeps hashCode and equals away from the backing collection so that the contract of each of those operations survives where the collection is a set or a list
  2. The view passes both of them to the backing collection, because the class reads hashCode and equals through only where the backing collection is a set or a list so that a caller who holds the view sees the same answers in those two cases
  3. The view passes both of them to the backing collection, because the class reads hashCode and equals through in the same way as every other query so that a caller who holds the view sees the very answers the backing collection would give
  4. The view leans on the equality of the root class, because the class keeps hashCode and equals away from the backing collection so that a caller cannot learn the contents of a collection it was never handed a reference to

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

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