- Abstract classes: Variables and abstract methods
- First of all, we want to think of the keyword: abstract (the keyword used to define abstract classes and methods)
- Then there are n more abstract methods and n>=0; means that there can be no abstract method in the abstract class.
- There can be ordinary member methods in an abstract class (different interfaces: only abstract methods)
- Abstract classes are not created to create objects.
- The difference between using an abstract class to implement an interface and using an ordinary class to implement an interface:
- Abstract classes allow the existence of abstract methods, so it is not necessary to implement all the abstract methods in the interface
- But the existence of abstract methods is not allowed in ordinary classes, so it is necessary to implement all the abstract methods in the interface
- Description: Implementing a unified specification
- Role: Subclasses of the class must implement all the abstract methods in the class
Java abstract classes and interfaces