Replies |
Mahendra123
Posted on: 3/22/2011 6:20:53 AM
|
Level: Starter | Status: [Member] | Points: 25
|
Hi,
Please refer the below link
http://www.codeproject.com/KB/cs/abstractsvsinterfaces.aspx
Regards,
Mahendra
Abhisekjani, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
Mesh_2010
Posted on: 3/22/2011 6:34:17 AM
|
Level: Starter | Status: [Member] | Points: 25
|
Hi,
difference between an interface and abstract class
In the interface all methods must be abstract; in the abstract class some methods can be concrete. In the interface no accessibility modifiers are allowed, which is ok in abstract classes.
Thanks
RameSH sinGH
Abhisekjani, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
Geekgirl
Posted on: 10/25/2011 6:59:50 AM
|
Level: Starter | Status: [Member] | Points: 25
|
Abstract Class
1.It can contain Concrete methods(methods with implementation) So in other words, Abstract class can contain methods with both implemetaion
and without implementation
2.Multiple inheritance is not possible in case of abstract class
3.Access Specifiers are been Supported in abstract class
Interface
1.Does not contain any concrete methods
2.Multiple Inheritance is possible with interface
3.Access Specifiers are not supported in Interface
Abhisekjani, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
Abhisekjani, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
Interfaces and Abstract classes
*An Interface cannot implement methods.
*An abstract class can implement methods.
*An Interface can only inherit from another Interface.
*An abstract class can inherit from a class and one or more interfaces.
*An Interface cannot contain fields.
*An abstract class can contain fields.
*An Interface can contain property definitions.
*An abstract class can implement a property.
*An Interface cannot contain constructors or destructors.
*An abstract class can contain constructors or destructors.
*An Interface can be inherited from by structures.
*An abstract class cannot be inherited from by structures.
*An Interface can support multiple inheritance.
*An abstract class cannot support multiple inheritance.
Abhisekjani, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
Abstract Class:-
1) An abstract method is created by specifying the abstract type modifier.
2) An abstract method contains no body.
3) An abstract method is not implemented by the base class.
4) An abstract method is automatically virtual.
5) A derived class must override it.
6) Abstract class can have modifiers for methods,properties etc.,
7) An abstract class can implement a property.
8) The abstract modifier cannot be applied to static methods.
9) Properties can also be abstract.
10) A class containing abstract methods must be declared as abstract with the abstract specifier.
11) There can be no objects of an abstract class.
12) If a derived class doesn't implement all of the abstract methods in the base class, then the derived class must also be specified as abstract.
13) An abstract class can inherit from a class and one or more interfaces.
14) An abstract class can implement code with non-Abstract methods.
15) Abstract class can have constant and fields.
16) An abstract class can have constructors or destructor's.
17) An abstract class cannot be inherited from by structures.
18) An abstract class cannot support multiple inheritance.
19) If we add a new method to an abstract class then we have the option of providing default implementation and therefore all the existing code might work properly.
Interface:-
1) Interfaces cannot be instantiated directly.
2) Interfaces can contain events, method, indexer and properties.
3) An Interface can contain property definitions.
4) Interfaces contain no implementation of methods.
5) Classes and Structs can implement more than one interface.
6) An Interface can be inherited from by structures.
7) An interface itself can inherit from multiple interfaces (Interface can support multiple
inheritance).
8) An abstract class can implement a property.
9) If we add a new method to an Interface then we have to track down all the implementations of
the interface and define implementation for the new method.
Abhisekjani, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|