GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  DotNet
Go To First  |  Previous Question  |  Next Question 
 DotNet  |  Question 137 of 165    Print  
What is practical difference between abstract class and interface? What is practical implementation of polymorphism?

  
Total Answers and Comments: 4 Last Update: June 04, 2008     Asked by: rajthebest 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
April 14, 2007 06:55:23   #1  
sambit        

RE: What is practical difference between abstract clas...
abstract class: partially implemented.
use:used when u know some of the implementations.Ex-dataset
Here u know that tables can be stored but what dimensions......?
but u know tables have rows n columns and can be implemented.

interface: these are fully abstract.U can't imlement anything here.
Use:used for assigning methods 2 be implemented.
At the top level u can't decide(or make design decision) on the implementaion always & is taken care by the classes that implement them.

 
Is this answer useful? Yes | No
June 07, 2007 08:52:15   #2  
s.jabee        

RE: What is practical difference between abstract clas...
Abstract class :
1. Atleast one abstract method has to be present (method without implementation).
2. Generally are base classes (*)
3. Can contain Virtual methods (Methods has implementation in the Base class but still to be overridden in the derived class for polymorphism ).

Interface:
1. Forms a set of rules which the implementing class has to abide to.
2. Can appear in any level of the class hierarchy unlike Abstract Class which will be always Base class. (*)
3. Cannot contain other access modifiers for the methods apart from public which is by default.

 
Is this answer useful? Yes | No
January 22, 2008 00:54:27   #3  
AvinashB Member Since: January 2008   Contribution: 1    

RE: What is practical difference between abstract class and interface? What is practical implementation of polymorphism?
Practical implementation of Polymorphism is operator overloading.
 
Is this answer useful? Yes | No
June 04, 2008 14:24:30   #4  
shankan25 Member Since: June 2008   Contribution: 1    

RE: What is practical difference between abstract class and interface? What is practical implementation of polymorphism?
Interfaces


we can use interfaces when somebody to start from scratch to implement the method from interface or their orginal purpose was different from exits interface then they can use interface.

Also a class can implement more interfaces(multiple inheritance)

Interface all variable are public static and final and all methos by default public and abstract methods.

we cann't implement method in the interface instead based on the purpose the class imlpementing the interface have to implement the method for their own purposes.

just importing the package of interface will allow anyone to use interface so it's easy.

performance wise it's slow because there is extra redirection.

Abstract Class;


abstract class has morestructured and it has default implementation in it.

we can extend abstract clas but cann't instantiate.

Because it has default implementation third party usage is should be use this abstract class as a base class. it cause restructuring their own class and class can inherit from only one base class.

method we declaring abstract should have abstract key word and abstract method should be declared inside abstract class.

calss extending abstract class should be implementing abstract methods unless the subclass is abstract class.

it's more fast than interface.

it can contain not static and final variable and contain static methods.

 
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