Home > Back-end >  The difference between interface and abstract class
The difference between interface and abstract class

Time:10-08

1. An abstract class with common method, interface not
Member 2. An abstract class can have its own attributes and methods, the interface can have only public constants,
3. An abstract class dispensable, an approach to interface no constructor
4. Abstract class single inheritance, interface multiple inheritance

CodePudding user response:

Abstract class using the abstract keyword modifiers; Interface using the interface modification,
Abstract class has a constructor (don't write have implicit constructor), but can't be instantiated; Interface is not a constructor,
Abstract class can have the abstract methods, in general only abstract methods in the interface,
An abstract class can have variable; In the interface can be constant
An abstract class can only single inheritance class; Interfaces can inherit multiple
The implementation class can inherit a abstract class; But you can implement multiple interfaces

CodePudding user response:

https://blog.csdn.net/MrBaymax/article/details/84328918

CodePudding user response:

We can see this article: the difference between abstract class and interface

CodePudding user response:

  • Related