• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

interface

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public interface AQuestion
{
void someMethod();
}
Why is the class which implements AQuestion should have someMethod that must necessarily be public.
My thoughs is that since someMethod in AQuestion has default modifier, the overriding method could be default, protected or public?
Thank you.
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Susie,
Every method in an interface is implicitly 'public'. See JLS §9.4
Hope that helps.
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Susie,
All methods in an interface are automatically public (even though the modifier explicitly does not appear by the method). However while implementing the interface, you must declare the method as public. Otherwise compiler will assume that the method as default (package) visibility and will complain that you try to supply a weaker access privilege.
-Sandeep Nachane
www.tipsmart.com

[This message has been edited by Sandeep Nachane (edited July 13, 2001).]
 
Susie Chow
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got it. Thank you.
 
I don't always make ads but when I do they're tiny
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic