File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why cannot interface defined inside a public class have protected methods??

 
vaishali shah
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I needed some clarification. If i had a class say abcd in file abcd.java. Its possible to defined an interface xyz in it only it cannot be defined as public. ie to say that the interface would have package access. If this is the case why cant i have method in the interface which are protected.
public class abcd{


}

interface xyz{

}
 
Dieter Quickfend
Bartender
Posts: 543
4
Java Netbeans IDE Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
interface methods are implicitly public and abstract. They cannot have any other modifier than public, and you cannot say, for instance, "final void doThis();" in an interface, because it's implicitly abstract.

Default access for the interface itself is allowed, however.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic