File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Why cannot interface defined inside a public class have protected methods?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Why cannot interface defined inside a public class have protected methods??" Watch "Why cannot interface defined inside a public class have protected methods??" New topic
Author

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

vaishali shah
Greenhorn

Joined: Sep 27, 2009
Posts: 4
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

Joined: Aug 06, 2010
Posts: 543
    
    4

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.


Oracle Certified Professional: Java SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why cannot interface defined inside a public class have protected methods??