• Post Reply Bookmark Topic Watch Topic
  • New Topic

Interfaces and Abstract Classes  RSS feed

 
seshu Palamanti
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do we need Interfaces and Abstract Classes when you can as well do the same with either one of them?.

Regards
Thx in advance.
 
Kj Reddy
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use Interfaces when you know the behaviour but do not know implementation. Use Abstract Clsses when you know some properties, behaviour and may or may not know implementaion.
[ March 07, 2006: Message edited by: KJ Reddy ]
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, a class may implement any number of iterfaces, whilst it can only directly extend one class (which may be the abstract class in question). So interfaces are more flexible in this way...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!