.Net Framework Interview Questions and Answers
<< Previous Question Next Question >>
 Question: 2411 Page Views: 

Contrast the use of an abstract base class against an interface?



Posted By: Avi Date: 22 August 2009 07:37:40 AM
 Answer:

Abstract class can provides implementation for some methods and properties while Interfaces can provide only declarations.

In simple term all methods in an interface are abstract but in abstract class some methods are abstract.


Posted By: eTechPlanet


Date: 22 August 2009 07:37:40 AM

then an Interface can be implemented by base abstact calss and can be given partially implement.Like Interface MyInterface { void Add(); void Sub(); } public abstract MyAbstract:MyInterface { public abstract void Add(); public void Mul(int a,int b) { return a*b; } public class MyVirtual:MyAbstract { public override void Add() { return a+b; } } }


Posted By: palanivel


Date: 7 October 2009 01:11:04 AM

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.


Posted By: Johndecruse


Date: 12 February 2010 11:58:35 PM
Post a better Answer if you have
 
(Will show your Gravatar icon)  
  Country flag

Loading
Enter the text as shown in the image veRKbD
Related Questions
.Net Framework : Can we force garbage collection in .Net?

Can we force garbage collection in .Net?

Yes. Set all references to null and then call System.GC.Collect().
Category: .Net Framework Date: 8/28/2009 4:58:58 PM
.Net Framework : What is Marshaling?

What is Marshaling?

Marshaling performs the necessary conversions in data formats between managed and unmanaged code. CL....
Category: .Net Framework Date: 8/28/2009 7:04:46 AM
.Net Framework : What is the top .Net class that everything is derived from?

What is the top .Net class that everything is derived from?

System.Object
Category: .Net Framework Date: 8/28/2009 7:01:44 AM
.Net Framework : Can we allow a class to be inherited, but prevent the method from being overridden?

Can we allow a class to be inherited, but prevent the method from being overridden?

Yes. Define the class as public and make the method sealed.
Category: .Net Framework Date: 8/28/2009 6:59:11 AM
.Net Framework : What is an interface class?

What is an interface class?

Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, inter....
Category: .Net Framework Date: 8/28/2009 6:56:01 AM