what is the difference between Interface and abstract classes

Posted by kamesh122-10906 under C# on 2/12/2012 | Points: 10 | Views : 3458 | Status : [Member] | Replies : 5
i want to know when we use interfaces and when we use abstract classes exactly?

kamesh


Responses

Posted by: Gow.net on: 2/12/2012 [Member] Starter | Points: 25

Up
0
Down
An abstract class is a class that can not be instantiated but that can contain code.
An interface only contains method definitions but does not contain any code. With an interface, you need to implement all the methods defined in the interface.

gowthaman8870226416

kamesh122-10906, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 2/12/2012 [Member] Silver | Points: 25

Up
0
Down

Hi,
These links will help you to understand the difference between interface and abstract class.

http://www.codeproject.com/Articles/11155/Abstract-Class-versus-Interface
http://www.codeproject.com/Articles/36870/Abstract-Class-Vs-Interface

Thanks,
Sanjay

kamesh122-10906, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vahidbakhtiary on: 2/12/2012 [Member] Starter | Points: 25

Up
0
Down
hi
An abstract class is a class that is only partially implemented by the programmer. It may contain one or more abstract methods. An abstract method is simply a function definition that serves to tell the programmer that the method must be implemented in a child class.

An interface is similar to an abstract class; indeed interfaces occupy the same namespace as classes and abstract classes. For that reason, you cannot define an interface with the same name as a class. An interface is a fully abstract class; none of its methods are implemented and instead of a class sub-classing from it, it is said to implement that interface.
i hope helpful

kamesh122-10906, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abhisekjani on: 2/12/2012 [Member] Starter | Points: 25

Up
0
Down
Following are the difference between abstract and interface

1----Abstract classes can have concrete methods while interfaces have no methods implemented
2----Interface do not come in inheriting chain,while abstract class come in


kamesh122-10906, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naraayanan on: 2/13/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
Check this link
http://sadi02.wordpress.com/2008/05/08/what-is-difference-in-an-abstract-class-and-an-interface/

Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

kamesh122-10906, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response