Java 在代码片段的Loc1处可以应用哪些注释

Java 在代码片段的Loc1处可以应用哪些注释,java,interface,annotations,Java,Interface,Annotations,我不确定什么是正确答案,请帮助,请帮助,请帮助,请帮助 @interface Resource { String name(); int priority() default 0; } /* Loc1 */ class ProcessOrders { } Which two annotations may be applied at Loc1 in the code fragment? (Choose two.) A. @Resource(priority=100)

我不确定什么是正确答案,请帮助,请帮助,请帮助,请帮助

@interface Resource {
    String name();
    int priority() default 0;
}

/* Loc1 */
class ProcessOrders {  }

Which two annotations may be applied at Loc1 in the code fragment? (Choose two.)
A. @Resource(priority=100)
    B. @Resource(priority=0)
    C. @Resource(name="Customer1", priority=100)
    D. @Resource(name="Customer1")
    E. @Resource

看起来你正在通过考试或其他什么:)

看,在java中,注释中的参数可以有默认值,如
优先级
,或者在您的示例中定义为没有默认值(如
名称

现在,如果您没有定义默认值,这是一个强制参数,您必须指定它,否则如果您没有指定任何东西,将使用默认值

如果不定义强制参数,代码甚至无法编译


记住这一点,在你的答案中选择那些定义了
名称
,并且可以选择定义
优先级
);)

答案应该是C和D,对吗?所有建议的答案都是A和B,这让我很困惑。