It's exactly like Pramod said. Don't confuse the modifiers of the interface itself with the modifiers of the methods declared in this interface! The methods have public access by default but the interface doesn't if you leave out the public keyword!
As it seems you're trying to learn the Java language at the moment. I'd suggest you take an IDE of your choice like Eclipse or Netbeans and just use it to play around a little. The IDE knows all the syntax details and you can test everything you're curious about This will save you a lot of time and answer most of your questions.
Additionally you can always take a look at the Java language specification for more details but don't worry if you don't understand all the subtle details at once.
Marco [ May 22, 2008: Message edited by: Marco Ehrentreich ]
As it seems you're trying to learn the Java language at the moment. I'd suggest you take an IDE of your choice like Eclipse or Netbeans and just use it to play around a little.
A better way to start off is to type the java code in a plain editor like Notepad, WordPad. If required and preferred, you can use a rich editors like EditPlus, Textpad so that you get the syntax highlighted with different colours and automatic highlighting of matching curly braces, paranthesis marker etc.,
But never go for an IDE (Integrated Development Environment) which helps you out with the autocompleting of many syntax as they are existing for Rapid Application Development. Please keep that in mind and don't ever go for any IDE until you are very much compliant with the BASICS and foundation of the language!
The IDE knows all the syntax details and you can test everything you're curious about This will save you a lot of time and answer most of your questions.
This is the major reason for avoiding an IDE in the beginner's stage!
I learnt alot of my Java using Eclipse and it does take a bit of your own initiative to look up why certain things are not working, and not just click an auto fix button (as opposed to being forced to when you use a bog standard text editor). In terms of learning which methods are available to what classes and reading API as you go along, all these things are positive things when you are learning and things a normal text editor doesn't provide. The only downside is the fact that you are not forced to look up why certain things are problems, but like I said, if you are willing to learn and understand why things are the way they are and not take an IDE's word for it, using one is no bad thing. It's a matter of how you prefer to learn I feel. [ May 22, 2008: Message edited by: Mustafa Musaji ]
You are right to certain extent. But all what we talk about is the beginner's stage and especially because of the IDE's syntax autocompletion feature, I bet very few people only remember the syntax (in terms of methods in a class, to depict an example), as all would have been taken over by the IDE.
It is called as context sensitive help, wherein placing a dot after a reference name fetches you the list of all available methods and presssing an enter key would complete the method name with even prefilled arguments to the same. This way, your "real learning ability" is going for a toss!
That's what is the general opinion of all i believe! and most of us agree to it!
Just to add, not just syntax autocompletion in the list.. there are much more. Like you can extract, encapsulate fields from a class and generate an interface out of it., autogenerated code/methods for a class/servlet etc,. autogenerated javadoc for the class/methods, likewise the list continues!