フリー問題

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

問題文

An annotation type is declared with the use of a type as its only target, and a build then rejects the spelling that puts the annotation in front of a fully qualified class name while it accepts the spelling that puts the annotation right in front of the last name in it. What is the standing rule, and what supports it?

選択肢

  1. The name that the annotation sits closest to has to be a type, because the language reads the annotation as a modifier of the declaration in that position and only a type may be modified where a declaration is expected
  2. The name that the annotation sits closest to has to be a type, because a package name is the kind that the simple name in front of the dots carries and the language bars an annotation from every location where that kind applies
  3. The place where the annotation sits inside the name is free, because the reading of a qualified name walks from left to right and each dot passes the annotation along to the term that follows it
  4. The place where the annotation sits inside the name is free, because the compiler folds the whole qualified name into one term and any annotation in front of it reaches the class that the term denotes

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

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