What is the difference between Interface and Abstract Classes?

Questions:

What is the difference between Interface and Abstract Classes?

Sample Answer:

Abstract classes and Interface classes are more over the same but following are the key differences between both of them:

  • Abstract classes can have properties whereas Interfaces cannot have properties.
  • Abstract classes can have methods of type public and protected whereas Interface classes can have methods of type public only.
  • All the methods that we declare in the Interface classes are by default abstract and hence need to have to explicitly specify the keyword “abstract”.
  • Classes that are inheriting from another class can implement an Interface at the same time.

Related Posts