Reputation: 1488
I am experimenting the questions from Oracle for the Java 7 Associate certification. The application for the windows is created by Oracle Press (probably). 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:
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. A and B are incorrect. The private and protected access modifiers cannot be used with classes and interfaces.
Upvotes: 2
Views: 211
Reputation: 3201
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).
Upvotes: 2
Reputation: 121998
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. Absence of that causing the confusion here.
Upvotes: 2