Features of abstract classes:
1, the method is an abstract method only if the declaration is not implemented, it needs to be abstracted, the abstract method must be defined in the abstract class, and the class must also be abstract.
2, abstract classes cannot be instantiated. Why? Because it doesn't make sense to invoke an abstract method.
3, an abstract class must have its subclasses covered by all the abstract methods, the subclass can be instantiated, otherwise, the subclass is an abstract class.
4, is there a constructor in the abstract class?
There, used to initialize the subclass object.
5, can abstract classes not define abstract methods?
OK. However, it is rare to have the class create an object. The object of the AWT adapter is this class, usually the method in this class has the method body, but there is no content.
Abstract class Demo
{
void Show1 ()
{}
void Show2 ()
{}
}
3, abstract keywords can not coexist with those keywords?
Private, No.
Static No.
Final No.
4, the similarities and differences between abstract class and general class.
Same point:
Both abstract and generic classes are used to describe things, and members are set internally.
Different:
1, the general class has enough information to describe things.
Abstract classes may not have enough information to describe things.
2, abstract methods cannot be defined in general classes, only non-abstract methods can be determined.
Abstract methods can be defined in abstract classes, and non-abstract methods can also be defined.
3, the generic class can be instantiated.
Abstract classes cannot be instantiated.
5, the abstract class must be a parent class?
Yes. You can instantiate a child class only if it needs to overwrite its method.
Summary of the abstract class of Java learning