C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » General »

Normal class vs Abstract class vs Interface


Posted Date: 01 Jul 2009    Resource Type: Articles    Category: General
Author: ismailMember Level: Bronze    
Rating: 1 out of 5Points: 5



I have read many articles about normal class vs abstract class vs interface class I think i m cleared now on the difference b/w these 3. I think many of you also cleared about this concept but the real test for all of us is where to use them. When to use which one. I try my best to elaborate these concepts.

First i am going to define the basic definition of these three concept.


Normal class:

Normal class have definition of functions and variables and their
declaration as well.




Abstract class:

Abstract class have function and variables with definition
and declaration as well like the normal classes.
We can not make instance of Abstract Class.




Interface class:

Interface class have functions and variables with only definition.
We can not make instance of Interface Class.



Now a million dollar question when to use these classes?

Lets take an example

A Content management system for Media, Media is a generalize form of TV,
RADIO & NEWSPAPER


MEDIA

*
TV
*
RADIO
*
Newspaper



Now the decision time



Should we make an instance of Media?

If yes then use normal class

else if no then use either abstract or interface class



if media have function let's say schedule() and it have some
default behavior
then use abstract class

else if every derived class have its own definition of schedule()
use interface class




abstract Class media

{

function abstract schedule()

{
/*default schedule behaviour*/

}

}


interface Class media

{

function schedule();
}


Interface class can give you multiple inheritance where abstract cannot.


Abstract class is faster then interface class because interface requires
extra in-direction.


the major draw back of interface class is that you have to define the
functionality in every derived class when every any function added in base
class other wise it will give an error.



Give you feedback on this article and give more examples on this topic

For more details, visit http://hubpages.com/hub/Normal-class-vs-Abstract-class-vs-Interface-class




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Objects  .  Normal class  .  Interface  .  Classes  .  Abstract class  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Java vs Javascript
Previous Resource: ASP.Net Interview question
Return to Discussion Resource Index
Post New Resource
Category: General


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use