Abstract class
Characteristics:
1, the method is abstract and needs to be modified only if the declaration is not implemented.
Abstract methods must be defined in an abstract class. The class must also be modified by the abstract.
2, abstract classes cannot be instantiated. Because invoking an abstract method is meaningless.
3, an abstract class must have its subclasses overriding all the abstract methods that can be instantiated. Otherwise, this subclass is an abstract class.
1, do abstract classes have constructors?
There, used to initialize the subclass object.
2, can abstract classes not define abstract methods?
OK. But it's rare. The purpose is to not allow the class to create objects. The adapter object for AWT is this class.
Usually the method in this class has a method body, but there is no content.
3, abstract keywords can not coexist with those keywords?
Private is not possible because abstract class subclasses cannot be overwritten. Privateabstract an illegal modifier combination.
Static is not possible, because static can invoke methods without objects, with no meaning. Static abstract an illegal modifier combination
Final is not possible because the final modified method cannot be overridden, but the abstract requirement is overwritten, conflicting.
4, the similarities and differences between abstract class and general class.
The same point: abstract and generic classes are used to describe things, and members are defined internally.
Different points:
1) The general class has enough information to describe the transaction.
Abstract classes describe transactions that may be insufficient information.
2) Abstract methods cannot be defined in a generic class.
Abstract methods can be defined in abstract classes, and non-abstract methods can also be defined.
3) A generic class can be instantiated.
Abstract classes cannot be instantiated.
5, abstract class must be a parent class?
Yes, you can instantiate a child class only if it needs to overwrite its method.
An overview of abstract classes in the Java language