| Feature | Interface | Abstract class |
| Multiple inheritance | A class may inherit several interfaces. | A class may inherit only one abstract class. |
| Default implementation | An interface cannot provide any code, just the signature. | An abstract class can provide complete, default code and/or just the details that have to be overridden. |
| Access Modfiers | An interface cannot have access modifiers for the subs, functions, properties etc everything is assumed as public | An abstract class can contain access modifiers for the subs, functions, properties |
| Core VS Peripheral | Interfaces are used to define the peripheral abilities of a class. In other words both Human and Vehicle can inherit from a IMovable interface. | An abstract class defines the core identity of a class and there it is used for objects of the same type. |
| Homogeneity | If various implementations only share method signatures then it is better to use Interfaces. | If various implementations are of the same kind and use common behaviour or status then abstract class is better to use. |
| Speed | Requires more time to find the actual method in the corresponding classes. | Fast |
| Adding functionality (Versioning) | 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. | 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. |
| Fields and Constants | No fields can be defined in interfaces | An abstract class can have fields and constrants defined |
Popular Posts
-
AJAX Toolkit provides a variety of controls and extenders. In this blog I would discuss use of Watermarkextender to <%@ Page Langu...
-
<script type="text/javascript"> function NumericTextBox(evt) { var charCode = evt.keyCode; if(evt.ctrlKe...
-
ASP.Net life cycle specifies, how: ASP.Net processes pages to produce dynamic output The application and its pages are instantiated and...
-
Any interactive web site has form input - a place where the users input different kind of information. This data is passed to ASP script, ...
-
<script type="text/javascript"> function AllowNumsOnly(evt) { var charCode = (evt.which) ? evt.which : event.keyCod...
-
Abstract Class: -Abstract class provides a set of rules to implement next class -Rules will be provided through abstract methods -Abs...
-
AJAX--> When you want a user to send data to your server — once they have filled out a form, for example — they normally have to s...
-
Web Service in ASP.NET A Web Service is programmable application logic accessible via standard Web protocols. One of these Web protoco...
-
Code to Print line by line: =First(Fields!ADDRESSLINE_1.Value, "Info_TBL_CLIENTMASTER")+","+System.Environment.NewLin...
-
Feature Interface Abstract class Multiple inheritance A class may inherit several interfaces. A class may inherit only one a...
Wednesday, August 8, 2012
Difference between Abstract Class and Interface
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment