• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

interface method public implicit

 
Ranch Hand
Posts: 128
MS IE Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
A default access modifier is not public, but why for an interface method, a default modifier (i.e. no modifier) makes the method public?
It should'nt right? default is default
If that's allowed, then why is'nt the interface itself allowed that implicity?
[ May 02, 2006: Message edited by: Allen Sylvester ]
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All interfaces are implicitly abstract and inclusion of that modifier is optional.
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should note the difference between default and implicit.
 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to reiterate what Owen said:

You can prefix any combination of public and abstract modifiers to method declarations in an interface and it still would be the same as not having a modifier...got it?

Eg:
interface Dummy
{
void doDummy();
}

interface Dummy
{
public void doDummy();
}

interface Dummy
{
abstrtact void doDummy();
}

interface Dummy
{
public abstract void doDummy();
}
are all the same.
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public is the only access modifier allowed for interface methods, so a default access modifier of anything other that public would not make sense.
 
Allen Bandela
Ranch Hand
Posts: 128
MS IE Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm talking in a purist's way, I guess.
A default access modifier allows access , only in the same package.
why is'nt that rule followed in an interface. I know that an interface can have only public methods, then why is it not Mandatory to put a 'public' access modifier? well, this is just purist probably. okay anyway, thanks anyway
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!