aspose file tools*
The moose likes Beginning Java and the fly likes Interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Interfaces " Watch "Interfaces " New topic
Author

Interfaces

dude philips
Greenhorn

Joined: May 13, 2005
Posts: 1
Friends,

I am DudePhilips from India,a Gradute, started career in Java. I have a doubt regarding Interfaces. " Y interfaces can't be declared as protected?"

can any body please let me know?

:roll:


Pressured to be Gold from coal <br />urs <br />Dude
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Its by design. An interface is the point of communication between one program entity and any other program entity. If you restrict access to an interface, its no longer really an interface, if you follow?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Chris Staten
Ranch Hand

Joined: Sep 24, 2004
Posts: 101
Why would we want to declare an interface as protected? If you declare an interface as protected then only the other classes in the same package (or subclasses of the interface) could access it. With an interface the whole point is to allow ANY class to implement it so that the implementing class is guaranteed to have the exact method signature as any other class that is implementing the interface. They allow us to to get around the problems associated with multiple inheritance, but stil have that method signature guarantee. this way we know how to call the method and what to expect in return.

Besides, what�s to protect in an interface? None of the methods do anything until the interface is implemented and they are themselves implemented.
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4462
    
    6

An interface can actually be declared as protected or private.

See 9.1.1 of the JLS: http://java.sun.com/docs/books/jls/second_edition/html/interfaces.doc.html#78582

The access modifiers protected and private pertain only to member interfaces within a directly enclosing class declaration


Junilu - [How to Ask Questions] [How to Answer Questions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Interfaces