• 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

Interface methods

 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I downloaded JWhiz trial, and mentioned in its tips is that
"Interface methods can't be native, static, synchronized, final, private,
protected or abstract. "
Interface methods I presume are implicitly abstract. This contradicts above statement. And I think interface methods can also be static. Is it right?
Thanks, zeeshan.
 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
interaces are just models over how the class looks, so there arn't really any methods. There for they can't be abstract. They work similar to abstract methods, given that you have to implement them, but they are not abstract methods.
As far as static is concerned, you need code for it to work, hence they can't be static.
/Mike
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, I think Zeeshan is correct in his first assertion--interface methods are considered to be (implicitly) abstract. It is even possible (although discouraged) to use the "abstract" modifier with them. See JLS 9.4 for details.
However, interface methods can't be static _because_ they are abstract (static methods can't be overriden). Member types (classes and interfaces) within interfaces are considered to be implicitly static and public though--they would have to, as interfaces can't be instantiated.
Ranjan
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic