フリー問題

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

問題文

A subclass declares a method whose name and parameter list match a private method of its superclass, and a call made through a superclass typed reference still runs the body that sits in the superclass. What does the language say about the pair of declarations, and why?

選択肢

  1. The subclass declaration is a separate method of its own, because a private method is placed beyond the reach of the subclass by the compiler, so the return type and the exceptions it declares are checked against the root class instead
  2. The subclass declaration overrides the private one, because a method that matches the name and the parameter list of an inherited one takes its place at run time, so the return type and the exceptions it declares must be substitutable
  3. The subclass declaration is a separate method of its own, because a private method is beyond overriding and beyond hiding in the technical sense of those words, so the return type and the exceptions it declares stand free of any relationship
  4. The subclass declaration overrides the private one, because the language widens the access of the inherited method to the level of the subtype, so the return type and the exceptions it declares are read as a refined form of the original

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

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