Home > Back-end >  How do you answer this interview question?
How do you answer this interview question?

Time:09-20

When using abstract classes, when using the interface?

CodePudding user response:

You can implement multiple interfaces, but can only inherit an abstract class

CodePudding user response:

When you want to define a specification, and methods do not achieve, just want to let the implementation of a subclass to implement these methods;
Or a subclass has inherited the other classes, and to inherit a parent class, you can use the interface,

CodePudding user response:

https://www.cnblogs.com/rennix/p/6372626.html

CodePudding user response:

Interface is generally used as a method of extension, an abstract class is mainly used for multiple Shared attributes of abstract class

CodePudding user response:

An abstract class cannot be instantiated, so is to be inherited, using an interface to implement multiple inheritance

CodePudding user response:

I now is in accordance with the requirements of project implementation,

CodePudding user response:

Interface can be used as a component, the things you need to a component, realize the corresponding interface, quantity is not limit, an abstract class can also be regarded as components, but you can only put one

CodePudding user response:

Interface can realize multiple inheritance, but an abstract class can inherit a
  • Related