[英]Oracle Java 7 Certification: The private and protected access modifiers can be used with which entities?
I am experimenting the questions from Oracle for the Java 7 Associate certification. 我正在试验来自Oracle的Java 7 Associate认证问题。 The application for the windows is created by Oracle Press (probably). Windows的应用程序由Oracle Press创建(可能)。 They've sent it to me with the Book. 他们已随书寄给我。
Currently, I have one question which application says "wrong answer", when I say that all answers are correct. 当前,当我说所有答案都是正确的时,我有一个问题哪个应用程序说“错误答案”。 Could someone explain this? 有人可以解释一下吗? The question is that Inner classes and inner interfaces can be both private and protected, but the explanation says classes and interfaces can't be. 问题是内部类和内部接口可以是私有的也可以是受保护的,但是解释说类和接口不能是私有的。 Please find question and explanation below. 请在下面找到问题和解释。 I hope this is the right place to ask this kind of questionJ. 我希望这是提出此类问题的正确地方。
Question 题
The private and protected access modifiers can be used with which entities? (Choose all that apply.)
Answers: 回答:
A: Classes
B: Interfaces
C: Constructors
D: Methods
E: Data Members
Correct Answers from Oracle: 来自Oracle的正确答案:
C: Constructors
D: Methods
E: Data members
EXPLANA TION: C, D, and E. The private and protected access modifiers can be used with constructors, methods, and data members. 解释:C,D和E。private和protected访问修饰符可与构造函数,方法和数据成员一起使用。 A and B are incorrect. A和B不正确。 The private and protected access modifiers cannot be used with classes and interfaces. 私有和受保护的访问修饰符不能与类和接口一起使用。
The question is that Inner classes and inner interfaces can be both private and protected 问题是内部类和内部接口可以是私有的也可以是受保护的
Yes you are right. 是的,你是对的。 But we should treat them as Data Members of that Class which they are presented. 但是我们应该将它们视为所提供的该类的数据成员。 Since they are not individual classes,interfaces we should not say them. 由于它们不是单独的类,所以我们不应该说它们。
Ofcourse in the explanation they must mention the word TOP LEVEL . 当然,在解释中他们必须提到TOP LEVEL这个词。 Absence of that causing the confusion here. 缺少它会引起混乱。
I guess the trick here is that the question doesn't take inner classes and interfaces into account. 我猜这里的窍门是这个问题没有考虑内部类和接口。 Answers A and B only refer to top-level class and interface declarations (although not explicitly stated). 答案A和B仅指顶级类和接口声明(尽管未明确说明)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.