• 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

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can anybody answer this simple question........Can an interface be declared private or protected ?

Thanks.
 
Greenhorn
Posts: 7
IntelliJ IDE Hibernate Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the Java Lang Spec...

InterfaceModifier can be one of
public protected private
abstract static strictfp

Cheers,
TR
 
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the Java Language Specifications, 2nd Edition:

9.1.1 Interface Modifiers
An interface declaration may include interface modifiers:

InterfaceModifiers:
InterfaceModifier
InterfaceModifiers InterfaceModifier

InterfaceModifier: one of
public protected private
abstract static strictfp

The access modifier public is discussed in �6.6. Not all modifiers are applicable to all kinds of interface declarations. The access modifiers protected and private pertain only to member interfaces within a directly enclosing class declaration (�8.5) and are discussed in �8.5.1. The access modifier static pertains only to member interfaces (�8.5, �9.5). A compile-time error occurs if the same modifier appears more than once in an interface declaration.

9.1.1.1 abstract Interfaces
Every interface is implicitly abstract. This modifier is obsolete and should not be used in new programs.

9.1.1.2 strictfp Interfaces
The effect of the strictfp modifier is to make all float or double expressions within the interface declaration be explicitly FP-strict (�15.4).

This implies that all nested types declared in the interface are implicitly strictfp.



So top level interfaces can only be declared public, strictfp, and/or (unnecessarily) abstract.
[ January 12, 2005: Message edited by: Mike Gershman ]
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Within the context of a containing class, as any other class member, interfaces can be declared public, private, protected or with package accessibility.
 
Puja S
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mike and Edwin .
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic