Tag Archives: interface

ABSTRACT vs INTERFACE

ABSTRACT vs INTERFACE

Abstract Class Interface
1. It is mainly used in versioning scenarios (defining core functionalities). Interface is used as contract mainly.
2. We can use abstract as well non-abstract method. All methods are abstract only. Interface is pure abstract class.
3. We can inherit only one abstract class at a time. We can implement multiple interface.
4. All access modifier can be used. We can have only public access modifier for the methods.

à We can not create object of abstract class, though abstract can have constructors.

àWe can create instance of abstract class like:

AbstractClass obj = new SubClass();

eg:

TextWriter abstract class have two sub classes i.e. StreamWriter & StringWriter

TextWriter tObj = new StreamWriter();

Leave a comment

Filed under C#