Two Laptop Bag*
The moose likes Java in General and the fly likes Interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Interface" Watch "Interface" New topic
Author

Interface

Subhendu Dash
Greenhorn

Joined: Mar 24, 2011
Posts: 18
Do all methods in an Interface has by default Public visiblity mode..???
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Hi Subendhu, and welcome to the Ranch!

Your question is answered here.


luck, db
There are no new questions, but there may be new answers.
Subhendu Dash
Greenhorn

Joined: Mar 24, 2011
Posts: 18
why default access visiblity can't be used with interface methods.say for ex-if i have an interface and i want only the classes in the same package to implement and thus use it.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

if i have an interface and i want only the classes in the same package to implement and thus use it.

That's answered in the next sentence after the answer to your original question.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38044
    
  22
An interface represents the public face of the class which implements it. That is why all members have the same access.
Subhendu Dash
Greenhorn

Joined: Mar 24, 2011
Posts: 18
And if we want abstract methods that can be implemented only on the same package then we can use an abstratc class(by making the methods abstract and default ) rather than an interface..Isn't it???
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38044
    
  22
Yes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Interface
 
Similar Threads
How To Call Two Different Classes From the Main Program Using the Same API?
Home interface or Home Interface stub
Time Capsule
Writing an Interface
what results byte code in java