Thursday, March 28, 2002 01:31 PM
Interface:Only to define the contract
how the implementation should be called
but there is no idea about the implementation.It gives full freedom to the implementor and at the same time totally hides implementation details from the user(easy to use).
eg: javax.servlet.Servlet interface
Abstract class:Part of the implementation can be provided while defining the contract but it is incomplete.Somewhat like partially implemented interface ...half boiled.So instantiation is not possible
without full implementation by extending it.
So go for Abstract class if you have something to provide which is common to all implementation otherwise interface.