Saturday, April 3, 2021

What is the difference between Interface and Abstract Class in C#?

Difference between Interface and Abstract Class

Below are the common points to be remembered,

  • Abstract classes can have abstract plus nonabstract methods while Interfaces all methods needs to be abstract only.
  • Abstract classes can have variables and method implementation whereas Interfaces are not allowed to declare variables and the methods are abstract only. (No implementation)
  • Abstract class members are private by default even they can be changed, In Interface it is public by default and you cannot change the same.
  • To declare abstract classes Abstract keyword is used, for Interface it is Interface
  • Abstract classes and Interfaces are not allowed to create an instance.
  • Abstract classes can have a constructor but Interface do not. 

No comments:

Post a Comment

C# Interview Prep: 100 Common Questions for 0-3 Years Experience

Common C# Interview Questions  Basics of C# Language: What is C#? C# (pronounced C sharp) is a modern, object-oriented programming language...