difference b/w abstract method and interfaces
-
what is the difference b/w abstract method and interfaces
-
what is the difference b/w abstract method and interfaces
georgemathew2@hotmail.com wrote:
what is the difference b/w abstract method and interfaces
I think you mean an abstract class and interface. An abstract class is a class that cannot be instantiated. However, it can contain members (fields, properties, methods, etc.). Some members can be declared as abstract which means that they do not provide any functionality and any derived class is required to implement the behaviour. An interface does not contain any functionality or data. Some descibe it as providing a contract. If you implement the interface then you are contractually obliged to implement the members it specifies.
Upcoming FREE developer events: * Developer Day Scotland My website
-
what is the difference b/w abstract method and interfaces
Nothing, but then you asked the wrong question You should have asked "What is the difference between an abstract class and an interfaces?" In which case the answer would have been that an abstract class can contain some implementation detail whereas an interface just defines a contract that an implementing class must conform to.
-
what is the difference b/w abstract method and interfaces
Hi I guess you mean between an abstract class and an interface. An Interface is basically an abstract class. with an abstract class you define a class that can not be instanced with
new
the abstract class example of this interface:public interface MyInterface
{
void Foo(int Param);
}would be:
public abstract class MyAbstractClass
{
public abstract void Foo(int Param);
}so you see 2 important differences: 1) in an interface you don't need a modifyer as public/private/internal on the members. they all have the same visibility as the interface (int this case public) 2) in an interface every member is implicit abstract. but still there's a difference between an interface and a class. in an abstract class you can do this:
public abstract class MyAbstractClass
{
protected int myProtectedMember;
public abstract void Foo(int Param);
Public MyAbstractClass()
{
myProtectedMember = 100;
}
protected virtual void Inc(ref int Value)
{
Value++;
}
}--> you can implement functions that are accessible by a derived class only. a protected member is a private member that is visible for derived classes as well. --> the interface won't let you implement fuctions directly on it. --> an interface can not have a constructor and one more important difference between an abstract class and an interface: you can derive a class from exactly one other class, but from as many interfaces you want. there are some more differences (like implementation of classes that inherit a class/interface) but you'll see if you try:)
-
what is the difference b/w abstract method and interfaces
In my experience "b/w" means "backed with" so I have no idea what your question means.