aspose file tools*
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
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: 4529
    
    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: 4529
    
    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: 38363
    
  23
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: 38363
    
  23
Yes.
 
wood burning stoves
 
subject: Interface