GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  ADO.NET 2.0
Go To First  |  Previous Question  |  Next Question 
 ADO.NET 2.0  |  Question 2 of 19    Print  
What is difference in an Abstract Class and an Interface.

Abstract class can contain method definations also.

Interfaces are essentially having all method prototypes no definition

In short Interface is a abstract class having all methods abstract




  
Total Answers and Comments: 9 Last Update: March 03, 2009   
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Priestly George Varghese
 

Interface
All methods are abstract and there is no implementation.
No access modifiers are allowed.
Interfaces are essentially having all method prototypes no definition
We can achieve multiple inheritance through interface

Abstract class
Some methods can be concrete.
They have access modifiers
Contain method definitions also.
We can achieve only single inheritance and multi-level inheritance
It can not be instantiated



Above answer was rated as good by the following members:
mvenkatm, ravikumar nukala
September 29, 2005 00:51:05   #1  
prateeti        

RE: What is difference in an Abstract Class and an Int...

An Abstract class has abstract methods. An Abtsract class can not be instanitiated directly. All the abtract methods are implemented in the derived class. There is no multiple inheritance here.

Interface class also has abstract methods and all of them are public. You can have multiple inheritance with Interfaces.


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
December 09, 2005 10:53:10   #2  
sahu Member Since: December 2005   Contribution: 323    

RE: What is difference in an Abstract Class and an Int...

Ans:

In an interface class all methods are abstract - there is no implementation. In an abstract class some methods can be concrete. In an interface class no accessibility modifiers are allowed. An abstract class may have accessibility modifiers.


 
Is this answer useful? Yes | No
January 21, 2006 06:17:00   #3  
sabir        

RE: What is difference in an Abstract Class and an Int...
the interface will have all absract method the absract will contain one or more absract method all the methods the interface has to be implemented but it is not req to implemne t all the methods in absract class
 
Is this answer useful? Yes | No
February 24, 2006 01:28:38   #4  
Arivoli        

RE: What is difference in an Abstract Class and an Int...

Interface :

1. All the methods in the interface are abstract.
2. We can achieve multiple inheritance through interface.
3. All the methods in the interface should be without Access modifier. Implicitly public.

Abstract class:

1. Abstract class may contain abstract method and non-abstract method.
2. We can achieve only single inheritance and multi-level inheritance.
3. Abstract methods have Access modifiers.


 
Is this answer useful? Yes | No
July 05, 2006 06:07:53   #5  
munishm Member Since: July 2006   Contribution: 1    

RE: What is difference in an Abstract Class and an Int...

An Interface is created/used when we have different types of objects while an abstract class is used when there is a single root hierarchy.


 
Is this answer useful? Yes | No
August 30, 2006 07:29:47   #6  
Devaraja Rao, Ambekar        

RE: What is difference in an Abstract Class and an Int...

Abstarct class is like normal class with 2 specials. 1. It can not be instanciated 2. It can have abstarct functions. Abstract class is used in inheritance as super class where some common implementation is requried.

Example is Thread class

interface is different type than class. All the members are public and no implementation is allowed. Interfaces are used for 1. For declaring project level constants because all variables public final and static. 2. In delegation pattern for providing flexibilty of implementation.

Example is runnable interface


 
Is this answer useful? Yes | No
March 30, 2007 06:04:06   #7  
sahu Member Since: December 2005   Contribution: 323    

RE: What is difference in an Abstract Class and an Int...

Abstract class:

1. Abstract class may contain abstract method and concrete method(means having own implemantion).
2. Abstract methods have Access modifiers(Public protected internal etc).

Interface :

1. All the methods in the interface are abstract.
2. We can achieve multiple inheritance through interface.
3. Donot have access Modifiers by default is PUBLIC


 
Is this answer useful? Yes | No
October 09, 2007 02:50:58   #8  
Priestly George Varghese        

RE: What is difference in an Abstract Class and an Int...

Interface

All methods are abstract and there is no implementation.

No access modifiers are allowed.

Interfaces are essentially having all method prototypes no definition

We can achieve multiple inheritance through interface


Abstract class

Some methods can be concrete.

They have access modifiers

Contain method definitions also.

We can achieve only single inheritance and multi-level inheritance

It can not be instantiated


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
March 02, 2009 12:40:50   #9  
ajayms2000 Member Since: March 2009   Contribution: 2    

RE: What is difference in an Abstract Class and an Interface.
Besides the rules difference between of interfaces and abstract class keep this also in mind.

Abstract classes promotes high cohesion while interfaces provides loose coupling. High cohesion and loose coupling are considered as the best design strategy for complex software designs.

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape