• Post Reply Bookmark Topic Watch Topic
  • New Topic

abstract and Interface  RSS feed

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when we need of abstract class and when we need of Interface?Where we use singleton?
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving from SCJP to Java In General (Beginner) ...
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By definition all an interface's methods must be abstract. However, all it takes to be an abstract class is to declare 1 method as abstract. Therefore you could potentially make your decision based solely on whether you wish to provide your own implementation for several methods or leave it all up to/force the end user to provide their own.

Keeping in mind that you can only extend 1 class but can implement several interfaces so that also enters the design consideration hopefully.

Regards
Dan
 
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See http://faq.javaranch.com/view?InterfaceVsAbstractClass
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!