| Author |
Query :- Interface
|
Kartik Mahadevan
Ranch Hand
Joined: Feb 16, 2005
Posts: 44
|
|
Hii Irrespective of the fact how we define the Interface(as public or default) Why do we always define it's methods as public while implementing the interface? Thanks Regards M.Kartik
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
Interface methods are implicitly public, so the public keyword is somewhat redundant. However, a member of a class with no modifier is not implicitly public.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Layne Lund
Ranch Hand
Joined: Dec 06, 2001
Posts: 3061
|
|
As Paul tries to explain, even if you leave off the public access modifier, the compiler automatically assigns all interface methods to be public. This is specified in the Java Language Specification, so the real answer to your question about why we have to do it this way is: "Because Sun said so!" Layne [ February 22, 2005: Message edited by: Layne Lund ]
|
Java API Documentation
The Java Tutorial
|
 |
Mike Gershman
Ranch Hand
Joined: Mar 13, 2004
Posts: 1272
|
|
[/B]Irrespective of the fact how we define the Interface(as public or default) Why do we always define it's methods as public while implementing the interface?[/B]
Can you think of a situation where marking the methods of a default scope interface as default instead of public would make any difference? I can't.
|
Mike Gershman
SCJP 1.4, SCWCD in process
|
 |
 |
|
|
subject: Query :- Interface
|
|
|