Originally posted by Jitendra Jha:
Sorry for being so stupid!!
i think that a method in interface can only be public automatically if the interface is also public,else it will have a default access specifier!!
No, all the methods in an interface are always public. Whether or not the interface is public is not relevant to this.
Originally posted by Jitendra Jha:
also the last reply raised another question,
While overriding methods,is it mandatory to use the same access specifiers?I guess only return type,method_name and parameters need to be same?
Well, two things.
Here we are talking about implementing a method of an interface, not overriding one.
When overriding you do not have to use the same access specifier, just not a more strict one. (You can override a protected method in a subclass with a public one, just not with a private one)