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

All abstract methods Vs interface

 
Vikas
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

This is really a beginners' question and my question is if an abstract class has all of its methods "abstract" in it(i.e. no concrete methods) then what will be the difference between this abstarct class and an interface.

Thank you
 
Campbell Ritchie
Sheriff
Pie
Posts: 49411
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If all your methods are abstract you are better off writing an interface, because you can implement several interfaces in the same class, but only extend one class. Remember you usually miss out "public" and "abstract" in method declarations in interfaces.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic