Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can interfaces have methods which are declared abstract

 
Chandra Bairi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can interfaces have methods which can be declared with the keyword abstract.
i read a book which says that the keyword is superflous and would not compile does the code get compiled
for me it is compiling properly
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Section 9.4 of the Java Language Specification says

For compatibility with older versions of the Java platform, it is permitted but discouraged, as a matter of style, to redundantly specify the abstract modifier for methods declared in interfaces.
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The keyword does appear to be superfluous. A class implementing an interface with such a method will compile fine even if it makes the method concrete.
[ November 13, 2003: Message edited by: Jason Menard ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic