Abstract: This method is mainly used in abstract classes and abstract methods.
Abstract classes cannot be instantiated, such
Public abstract class test {
}
He can contain abstract methods
Public abstract class test {
Public abstract void defmethod ();
}
The abstract method is to let the subclass inherit and then define it, so that the abstract concept can be designed. For example, when an object-oriented design encounters a method with multiple designs, the design work can be handed over to the subclass when the base class is not designed for the time being, you can either continue to inherit the abstract concepts of its superclasses or define the abstract methods.
For example
Abstract class Test2 extends test {
........
}
The abstract method of the super class is still not defined, and the abstract concept is handed over to the subclass of test2.
Class Test2 extends test {
Public void demethod (){
}
}
Inherit from test to design abstract concepts. Although no statement exists in {}, it also means that we have made a design for it, a definition of nothing. Suppose that the definition can be written in.
Summary:
A method without a method body in a class is an abstract method.
Classes that contain abstract methods are abstract classes.
If a subclass does not implement all abstract methods in the abstract base class, the subclass can also become an abstract class.
We can declare a class without any abstract method as abstract, so that no matter what object is generated by this class.
Abstract modification method summary