Abstract (abstract) modifier, you can modify classes and methods
The 1,abstract modifier class makes this class an abstract class that will not be able to generate object instances, but can be declared as object variables, i.e. compile-time types, and abstract classes, like the semi-finished products of a class, require subclasses to inherit and overwrite the abstract methods.
The 2,abstract modification method makes this method an abstract method, that is, only the declaration (definition) is not implemented, and the implementation part is replaced with ";". A subclass inheritance implementation (overwrite) is required.
Note: Classes that have abstract methods must be abstract classes. But abstract classes are not necessarily abstract methods, they can be all concrete methods.
The abstract modifier must be placed in front of the class name when the class is decorated.
The abstract modification method requires that its subclasses overwrite (implement) this method. The method that the subclass overrides (implements) can be invoked in polymorphic mode when invoked, which means that the abstract method must be implemented in its subclass, unless the subclass itself is also an abstract class.
Note: The parent class is an abstract class, where there are abstract methods, the subclass inherits the parent class, and all the abstract methods in the parent class are implemented (overwritten), the subclass has the ability to create an instance of the object, or the subclass must be an abstract class. An abstract class can have a constructor method, which is the constructor of the parent class (abstract class) that the subclass needs to invoke when it constructs the subclass object.
For a simple example, here's an abstract class
Abstract class e{
public abstract void Show ();
Public abstract can be omitted
}
Then the other class inherits it, usually in order to implement the method inside it
Class F extends e{
void Show () {
Code to write specific implementations
}
}
Finally, a polymorphic phenomenon occurs when a parent class reference is defined in the main method to point to a subclass object, such as
E e=new F ();
E.show ();
Actually called the show () method inside the subclass