フリー問題

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

問題文

A team debates whether the comparator they wrote should override the equality method that it inherits. What does the interface say about that choice, and why?

選択肢

  1. Overriding that method is required of a comparator, because the interface says that it has to obey the general contract of the one it overrides, and any comparator that leaves it alone breaks that contract
  2. Leaving that method alone is the safe course, because the interface says that overriding it may let a program find that two comparators impose the same order, and only a gain in speed is at stake
  3. Overriding that method is required of a comparator, because the interface says that it may return the affirmative for another comparator that imposes the same order, and each holder counts on that answer
  4. Leaving that method alone is the safe course, because the interface says that overriding it may let a program find that two distinct comparators impose the same order, and every collection that holds one relies on that reading

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

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