• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Access Privileges of method in an interface

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
So far, I have been thinking that the default access privilege for a method in an interface is default.
I tried to following code snippet

and i got the following compile time error :
Test.java:50: get() in Test cannot implement get() in x; attempting to assign weaker access privileges; was public
class Test implements x {
^
1 error
But when the above code is changed as follows, it works fine.

Does this mean that the default access privilege of a method in an interface is public?
Could somebody please clarify.
Thanks
Babu
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,
All interface methods are by default public and abstract (even if you don't explicitly mention in the declaration).
Hence any class that implements the interface must declare the method to be public.
Hope it is clear now.
Good luck,
Bye.
 
Babu Subbu
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ohhh.. is it....
Thanks a lot for the clarification Vishy.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic