Abstaract and interface

Posted by Venu510 under ASP.NET on 7/4/2011 | Points: 10 | Views : 1145 | Status : [Member] | Replies : 6
Hi Friends!

Actually where we would use abstract calss and interface ?can any one expln with examples

Thanks & Regards
-------------------
Venu




Responses

Posted by: SheoNarayan on: 7/4/2011 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Hello Venu,

I can explain but just to avoid duplication, I am pointing to some resource on this website

http://www.dotnetfunda.com/interview/exam332-when-to-use-interface-over-abstract-class-.aspx
http://www.dotnetfunda.com/forums/thread1679-difference-between-abstract-interface.aspx

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Venu510, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakn2 on: 7/5/2011 [Member] Starter | Points: 25

Up
0
Down
abstract and inerface are used to define commom methods . but the main difference between them

all methods define in abstract class are may or may not implemented in derived classes but in interface

all methods which are defined in interface are implemented by derived class.

Thanks&Regards
LakshmiNarayana Nalluri.

Venu510, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: T.saravanan on: 7/5/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi,

Refer this link...
http://www.codeproject.com/KB/cs/abstractsvsinterfaces.aspx

Thanks,
T.Saravanan

Venu510, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Susanthampy on: 7/6/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Refer this links,

http://forums.asp.net/t/1240708.aspx/1?Difference+between+Abstract+class+and+interface



Regards,
Susan

Venu510, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 9/20/2012 [Member] Bronze | Points: 25

Up
0
Down
Abstract Class

1)An abstract class is a special kind of class that cannot be instantiated
2)Abstract class can only inherit from one abstract class.
3)An abstract class can provide complete, default code and/or just the details that have to be overridden.
4)Fast
5)An abstract class can have fields and constrants defined


Interface

1)Interface is not a class. It is an entity that is defined by the word Interface.
2) An interface has no implementation; it only has the signature or in other words, just the definition of the methods without the body.
3) A class can implement more than one interface
4)If various implementations only share method signatures then it is better to use Interfaces.
5)An interface cannot have access modifiers for the subs, functions, properties etc everything is assumed as public
6)No fields can be defined in interfaces

//Abstarct Class

public abstract class Vehicles

{

private int noOfWheel;

private string color;

public abstract string Engine

{

get;

set;

}

public abstract void Accelerator();

}

//Interface

public interface Vehicles

{

string Engine

{

get;

set;

}

void Accelerator();

}

Venu510, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 9/20/2012 [Member] Bronze | Points: 25

Up
0
Down
Please mark these also as answer .. That helps others who search the same..

Venu510, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response