aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Interface Theory 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 Theory" Watch "Interface Theory" New topic
Author

Interface Theory

Yogesh Chhawasaria
Ranch Hand

Joined: Apr 02, 2004
Posts: 53
Hi All Got this one wrong at the javaprepare site Mock test
http://www.javaprepare.com/quests/test.html
Which of the following are true about interfaces. Select the two correct answers.
A Methods declared in interfaces are implicitly private.
B Variables declared in interfaces are implicitly public, static, and final.
C An interface can extend any number of interfaces.
D The keyword implements indicate that an interface inherits from another.
I was sure that
C is corect
A is incorrect
Took a guess from the B and D
Can anyone elaborate the B part
Plz also post a good link for interface theory.
Thanks in advance.
P.S. I got a score of 87.75 in that test Hows That good enuf.


When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
If you look at the JLS, §9.3 Field (Constant) Declarations, you'll see this:

Every field declaration in the body of an interface is implicitly public, static, and final. It is permitted to redundantly specify any or all of these modifiers for such fields.

Interfaces are not classes - they are designed to provide an "interface" for dealing with an object. As some methods require constants for interaction, it is permitted to declare constants within an interface. However, you can not instantiate an interface so there is no reason for having a non-constant value (such as an instance variable) within an interface. Therefore, all fields declared within an interface are implicity public, static, and final.
I hope that helps,
Corey


SCJP Tipline, etc.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Interface Theory