Key points!!!!
1 , abstract class ( Abstract class ) and Interfaces ( Interface what are the similarities and differences?
same Point
* cannot be instantiated directly , but can be implemented through inheritance to implement its abstract method .
* are the technical basis for abstract programming, and realize a lot of design patterns.
different points
* The interface supports multiple inheritance , and abstract classes cannot implement multiple inheritance .
* interfaces where the abstract methods are all implemented
* Interfaces can only define abstract rules; Abstract classes can define rules and may also provide implemented members.
* An interface is a set of behavior specifications; An abstract class is an incomplete class that focuses on the concept of a family.
* Abstract classes do not necessarily have abstract methods .
* Interfaces only contain signatures for methods, properties, indexers , events, but cannot define fields and methods that contain implementations; Abstract classes can define fields, properties, and methods that contain implementations.
* Interfaces can be used for value types and reference types , and abstract classes can only be used for reference types . For example, a struct can inherit an interface and not inherit a class.
* The members in the interface are all public, and the member variables defined in the interface are actually constants.
* The methods in the interface are abstract methods
Java Interview Basics------"What are the similarities and differences between abstract classes and interfaces?