Difference between abstract class and interface
Answer Posted / mohammad mousa fanasheh
Multiple inheritance:
interface :A class may inherit several interfaces.
Subtract: 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.
Speed:
Interface Requires more time to find the actual method in the corresponding classes.
abstract class Faster
Adding functionality (Versioning):
In interface .. 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.
In abstract class ..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
Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
8. Oop-Why and were we use Interfacse and Abstract class.
What is biginteger and when would you use that?
What is a service contract, operation contract and data contract?
What is private constructor? And it's use?
What is the difference between machine config vs. Web config : Dot net architecture
Does .NET runtime offer Deterministic Destruction or not?
Explain hard disk and what is its purpose? : .NET Architecture
what are the events for a form?
Can you explain update progress control?
Explain the components required to develop mobile applications with .net mobile? : Microsoft dot net mobile
What is the problem with .net generics?
How to develop mobile applications using microsoft mobile internet toolkit (mmit) or .net mobile? : Microsoft dot net mobile
Why only boxed types can be unboxed?
4. Wcf- what Asych and Sych call and how that works
I am working with asp.net 2005 and Crystal report 10. I have an image field on my dataset to show on Crystal report.And the image is shows dynamically from database in image field of CR. The image field is showing well on my Crystal report on its first page with all other data but when i click to open second page of CR,it does not show any data on that.I found that this is because of adding the image field on crystal report. Because when i remove the image field from the CR then it will run both the pages of CR. I am using the Page Load event to bind CR data with Database. And i have already check with the Init event to bind CR , but it still not shows the data on second page when i use image field on that. Please give solution for that.....