Difference between an abstract class and interfaces


Difference between an abstract class and interfaces
  1. A class can implement any number of interfaces but a subclass can at most use only one abstract class.
  2. An abstract class can have non-abstract methods (concrete methods) whereas all methods of interfaces must be abstract.
  3. An abstract class can declare or use any variables whereas an interface is not allowed to do so.
  4. An abstract class can have a constructor declaration whereas an interface cannot.
  5. An abstract class is allowed to have all access modifiers for all of its member declarations whereas in an interface we cannot declare any access modifier (including public) since all the members of an interface are implicitly public.

Comments

Popular posts from this blog

.NET Design Patterns Tutorial - MVC, MVP and MVVM Design Patterns

C# Coding Standards and Naming Conventions

What is the difference between C and C++?