• Post Reply Bookmark Topic Watch Topic
  • New Topic

interface  RSS feed

 
Arun Prasath
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the default access modifier for interface?
(both for top level interface and iner inteface)
 
Jay Suttiruttana
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I remember correctly, public abstract is the default access modifier for the interface's method. I normally think of interface as an abstract class
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An interface cannot have the protected or private access modifier, either on the interface declaration, or for methods.

As far as 'default' goes, well, if you don't specify public, the access modifier defaults to the default, which is essentially package.

That certainly applies to top level.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The default access for the interface itself is pachage, unless the interface is nested within anoter interface. The default for anything within an interface (including methods, constant fields, and nested types) is public. From Arun's question, it's not clear whether he's talking about the interface itself, or what's inside, so I think it's important to make that distinction.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!