Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why private interface

 
lee nelson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,
Can any one tell me what's the use of an private and
protected interface
 
Ramesh Donnipadu
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Top level (package level) interfaces are public by default. This is trye even if you don't explicitly define any modifier. You can't define private/protected interfaces at package level.
However, interfaces defined inside a class can have any accessibility including protected and private. Let us see where these can be used.
Supposing A be top level class and IFace be inner interface defined with private modifier. Then all inner classes defined inside class A can inherit IFace. Subclasses of A cannot define inner classes that implement IFace.
With protected modifier subclasses of A can define inner classes which can implement IFace.
-Ramesh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic