*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Interface is static??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Interface is static???" Watch "Interface is static???" New topic
Author

Interface is static???

RAGU KANNAN
Ranch Hand

Joined: Dec 16, 2005
Posts: 103
Hello,

For the following question there answer's are "A" and "E". But it looks "B" also correct.The whizlab says wrong because the interface is internally static. I read K&B book says interfaces are internally public and abstract. So I couldn't understand, pls explain to me.

Thanks, Raghu.K

Dave Casman
Greenhorn

Joined: Sep 12, 2006
Posts: 6
The answer is, you get a compile error at line 3.



Your voidf method does not have a return type. What was the question?
Meena R. Krishnan
Ranch Hand

Joined: Aug 13, 2006
Posts: 178
First of all, at line 3 there is a typo, there should be a space between void and f().


As far as the option B, I just compiled it and with B at line 6 and got an error saying

"The member interface J can only be defined inside a top-level class or interface"
RAGU KANNAN
Ranch Hand

Joined: Dec 16, 2005
Posts: 103
Thanks Krishnan, for correcting the "TYPO"

Dave,
My Question is why answer [B] "Interface J{}" is not allowing in Inner class?

Thanks, Raghu.K
Meena R. Krishnan
Ranch Hand

Joined: Aug 13, 2006
Posts: 178

There is no such thing as an inner interface. Because, interfaces are always implicitly static. They are always top-level, not inner. Inner classes cannot have any static modifiers at all.


from --> http://www.developer.com/java/article.php/859381
Aniket Patil
Ranch Hand

Joined: May 02, 2006
Posts: 218
From JLS:

"Inner classes may not declare static members, unless they are compile-time
constant fields" and

"Member interfaces are always implicitly static so they
are never considered to be inner classes."

Interfaces are not implicitly public, unless you declare them to be.
[ September 17, 2006: Message edited by: Aniket Patil ]

SCJP 5.0 | SCWCD 1.4 <br /> <br />If you don't know where you are going, any road will take you there!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Interface is static???
 
Similar Threads
Argument-Defined Anonymous Inner Class
How to check the type of a variable
Integer
declaration of an inner class:
Reg:- Interface internal Syntex.