This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Nested Interface Declarations within Interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Nested Interface Declarations within Interfaces" Watch "Nested Interface Declarations within Interfaces" New topic
Author

Nested Interface Declarations within Interfaces

Zak Nixon
Ranch Hand

Joined: Sep 27, 2003
Posts: 126
Hello All,
I was wondering about the following question:
(from Dan Chisolm's test)
Which of the following are modifiers that can be applied to an interface
that is a member of a directly enclosing interface?
a. abstract
b. implements
c. final
d. private
e. protected
f. public

I would definately say a,c,f but the answer is a,c.
When an interface declares a member of itself, doesn't all
fields become inherently public,static,final, and all methods
are public,abstract. I would think that declaring an nested interface/class
would also make them inherently public,abstract, and final, since they would be declared in the scope of the interface.
What am I missing here?
Zak Nixon
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
Zak,
The answers on my exam are actually a and f. My exam does not list option c among the correct answers. The reason is because the modifier, final, is never applicable to an interface declaration. The explanation provided by my exam is as follows.

All interfaces are implicitly abstract. The explicit application of the abstract modifier to an interface declaration is redundant and is strongly discouraged. The declaration of an interface within the body of an enclosing class or interface is called a member type declaration. Every member type declaration appearing within the body of a directly enclosing interface is implicitly static and public. Use of the access modifiers, private or protected, is contradictory and results in a compile-time error. In contrast, the modifiers, private and protected, are applicable to a member type declaration appearing within the body of a directly enclosing class. The modifier, final, is never applicable to an interface. The keyword, implements, is not a modifier.


Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
naren babu
Greenhorn

Joined: Sep 20, 2003
Posts: 8
I agree with Dan's reasoning
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Nested Interface Declarations within Interfaces