File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes interface method public implicit Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "interface method public implicit" Watch "interface method public implicit" New topic
Author

interface method public implicit

Allen Bandela
Ranch Hand

Joined: Feb 16, 2006
Posts: 127

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 ]

Life is like a day. If the day is of no use, neither a month or a year.
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
All interfaces are implicitly abstract and inclusion of that modifier is optional.
Dick Eimers
Ranch Hand

Joined: Apr 15, 2006
Posts: 40
You should note the difference between default and implicit.


<a href="http://eimers.blogspot.com" target="_blank" rel="nofollow">eimers.blogspot.com</a>
Aniket Patil
Ranch Hand

Joined: May 02, 2006
Posts: 218
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.


SCJP 5.0 | SCWCD 1.4 <br /> <br />If you don't know where you are going, any road will take you there!
Kristian Perkins
Ranch Hand

Joined: Mar 27, 2006
Posts: 32
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

Joined: Feb 16, 2006
Posts: 127

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
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: interface method public implicit
 
Similar Threads
question from Sun guoqiao mock exam2
Overriding in interface
S&B Practice Exams, Test 1, # 14 question
interface
Interface Implementation