What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 7624 |  Welcome, Guest!   Register  Login
 Home > Forums > C# > Difference between interface and abstract class ...
Abhisekjani

Difference between interface and abstract class

Replies: 7 | Posted by: Abhisekjani on 3/22/2011 | Category: C# Forums | Views: 24570 | Status: [Member] | Points: 10  


what is the difference between abstract class and interface...........


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Mahendra123
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
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
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 

Debal_saha@yahoo.com
Debal_saha@yahoo.com  
Posted on: 1/31/2012 2:03:53 PM
Level: Starter | Status: [Member] | Points: 25

Abhisekjani, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Bageshkumarbagi
Bageshkumarbagi  
Posted on: 10/5/2012 6:13:24 AM
Level: Starter | Status: [Member] | Points: 25

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 

Satyapriyanayak
Satyapriyanayak  
Posted on: 1/24/2013 12:19:47 AM
Level: Bronze | Status: [Member] | Points: 25

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 

Reply - Please login to reply


Click here to login & reply

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/22/2013 5:03:05 PM