• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Interface Theory

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic