フリー問題

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

問題文

A class named Outer contains a static nested class named Inner. How does code in an unrelated class create an instance of Inner?

選択肢

  1. By creating an Outer first and then writing outer.new Inner(), because a nested class is tied to an instance of the class around it
  2. By writing new Outer.Inner(), because such a static nested class needs no instance of the class around it
  3. By calling a factory method on Outer, because a static nested class has no constructor that callers can reach
  4. By writing new Inner() after importing Outer, because a nested class becomes visible under its simple name everywhere

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

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