In this article we will discuss about what is the difference between abstract class and interface in C#.Net.
Also check out:
- How to handle exception in sql server stored procedure?
- How to disable right click by using jQuery in asp.net?
- Ado.Net interview questions in Asp.Net
Abstract class:
- This is a special type of class that cannot be instantiated.
- Abstract class is a class which contains both abstract method and non abstract method.
- Abstract class have method definition and implementation.
- It can contain acessmodifiers for function properties.
- It doesn't support multiple inheritance, it can have constructor and destructor.
- We can declare a class abstract by using keyword abstract.
Interface:
-An interface is not a class. It is an entity that is defined by the word Interface.
-It has only signature or in other words just the definition of the methods without the body.
-Interface has only signature.
-All the methods are public,it doesn't have access modifiers controls.
-All the methods are abstract.
-It doesn't have constructor and destructor fields.
-It supports multiple inheritance in the object oriented language.
-A class may inherits several interfaces.
Also check out:
- How to handle exception in sql server stored procedure?
- How to disable right click by using jQuery in asp.net?
- Ado.Net interview questions in Asp.Net
Abstract class:
- This is a special type of class that cannot be instantiated.
- Abstract class is a class which contains both abstract method and non abstract method.
- Abstract class have method definition and implementation.
- It can contain acessmodifiers for function properties.
- It doesn't support multiple inheritance, it can have constructor and destructor.
- We can declare a class abstract by using keyword abstract.
Interface:
-An interface is not a class. It is an entity that is defined by the word Interface.
-It has only signature or in other words just the definition of the methods without the body.
-Interface has only signature.
-All the methods are public,it doesn't have access modifiers controls.
-All the methods are abstract.
-It doesn't have constructor and destructor fields.
-It supports multiple inheritance in the object oriented language.
-A class may inherits several interfaces.