• 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

Easy interface question

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I'm planning to taje the SCJP exam soon and have been using the red and blue Sierra/Bates study guide. I've found it to be very good and easy to read. One question I have which I hope someone can help me clear up is
up is whether interfaces are implicitly public.
On page 133 in the 2-minute drill it states "Interfaces are by default
public and abstact - explicit declaration of these modifiers is optional"
On page 115 however it states "The public modifier is required if you want
the interface to have public rather than default access". Which is correct.
I hope I'm not reading this wrong but they seem to contradict one another.

Thanks in advance
Bruce
 
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bruce, try this code out:

The class Sub above doesn't compile with this error:

If you place interface I in the same source file as Super, it won't compile either. To be visible outside of its package, it must be given public access modifier.
[ November 03, 2003: Message edited by: Vad Fogel ]
 
Vad Fogel
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please refer to K&B Errata page
and search for page 133. This error has been recorded:


Page 133, First bullet 3/03/03
Change:
Interfaces are by default..
To:
Interface methods are by default


Hope this helps.
[ November 03, 2003: Message edited by: Vad Fogel ]
 
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy -- yes, just wanted to clarify (although Vad's already done that perfectly here, and THANK-YOU Vad):
* interface METHODS are always public/abstract, whether you say it or not.
* interfaces can be either default or public, but the default is... default
cheers,
Kathy
 
Yat Cheung
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey thanks for clearing that up. Didn't know about the errata page but will use it from know on. Great book btw Kathy.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic