What is the difference between abstract class and interface?

Hello Friends,
Tell me the difference between abstract class and interface?

An interface describes a contract for a class to follow, it must implement the methods verbatim described within the interface, and abstract class does not require that.

An abstract class is an actual class (unlike an interface, which isn’t a real class), it can’t be instantiated, so the only way you can use an abstract class is by inheriting it. You will typically inherit it because the class you are creating is a type of the abstract class. Thus giving your new class a baseline of functionality.

Abstract class is a class that contain complete and abstract both type of member and it can not be instantiated, Abstract classes are one of the essential behaviors provided by dot net. That leaves one or more method implementations unspecified by declaring one or more methods abstract.

Interface is a type which contains only the signatures of methods, delegates or events, it has no implementation, Implementation of the methods is done by the class that which implements the interface. If there are data fields defined in an interface, then they are implicitly defined to be:
• public.
• static, and
• final

Interfaces and abstract methods have been described across the Internet millions of times already. I doubt you’ll get a better explanation on here than you will anywhere else on the web.

That being said, if you are coming from a Java background your idea of interfaces may differ, especially when it comes to explicit interface implementation, which to my knowledge you cannot do in Java.

If you have a complex set of business rules, it might also be worth looking at covariance, invariance, and contravariance. Again, it’s been done to death elsewhere on the web, so use Google to find the explanation that works well for you, and then try building on these principles.