• 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 definition

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everybody,
I want to know if it's legal to use abstract modifier with interface definition. i.e
abstract interface E{}
I know that interface is implicitly abstract & it is better not to use abstract modifier explictly but if we use it then it compiles fine. So if the question is whether it is legal or not what should be the answer.
Regards
Kiran.
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kiran,
The reason it compiles fine should tell you it is legal. The compiler has no problems with this declaration. However, it is redundant.
Ajith
 
KN
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ajith. Actually there was a Question in Sun Certified Java Programmer Book & it says that this is illegal. That left me in doubt.
Regards,
Kiran.
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not an expert at this. I tried it myself andf it compiles and I am satisfied with Ajith's answer. However I think I know why the book says it's wrong...because according to the book, an abstract method cannot have a body. So the curly braces are wrong.
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
antraarora,
abstract interface E{}
is an interface, not a method declaration.
 
reply
    Bookmark Topic Watch Topic
  • New Topic