====================== Abstract =============================
Abstract concepts
- An abstract class cannot be directly instantiated. Only its non-Abstract subclass can be instantiated.
- Abstract classes do not necessarily contain abstract methods. abstract methods must be in abstract classes.
- Abstract METHODS only have method headers and no method bodies.
- Constructor methods and class methods (static-modified methods) cannot be declared as abstract methods.
- The subclass of an abstract class must provide the specific implementation of all methods of the abstract class, unless the subclass is also an abstract class.
- Abstract cannot be used with private/static/FINAL.
Abstract meaning
Unified interface for defining implementation methods
====================
Interface
====================
Interface Concept
A set of methods and variables, all composed of abstract methods, modified with implements, is called an interface.
Note:
- A class can implement multiple interfaces. To implement an interface class, you must override all member methods in the interface.
- All the variables in the interface are final static variables. (Final, static)
- You cannot create an instance because the interface does not have a constructor.
- The interface is not a class and may be a bit absolute, but it can be said that it is not a class derived from class.
======================
Differences between an abstract class and an interface ========================
- The interface is defined by interfaces. The abstract class is class;
- Methods In interfaces are abstract methods. Methods in abstract classes may or may not exist;
- The interface adopts the multi-Inheritance Mechanism, and the abstract class adopts a single Inheritance Mechanism;
- An abstract class represents an inheritance relationship, and an interface represents a function. The two are used to understand the problem domain.