vijai ganesh wrote:I know the definiton and how to use both interface and abstract....
but what is the use of both interface and abstract classes..
When you create an interface, you're defining a contract for what a class can do, without saying how the class will do it. It is up the the developer implementing the interface, how the class runs internally.
When you define an abstract class, you still defining a contract, but you can implement the class partially. When you know that some methods will be the same for all subtypes, you can provide those in your abstract class.
And finally, classes can implement many interfaces, but only can extend one class.