I. Abstract overview
When we analyze things, we find common content, and then we extract them upwards. There is a special case where the method function declaration is the same, but the method function body is different.
Then it can be extracted, but only the method declaration is extracted, and the method body is not extracted. Then this method is an abstract method.
Second, the characteristics of abstract class
Abstract methods can only be used in abstract classes
abstract classes and abstract methods must be modified by an abstract
Abstract classes cannot create objects (cannot be instantiated)
There can be non-abstract methods in abstract classes
The relationships of abstract classes and classes are also inherited
A class inherits an abstract class or overrides all abstract methods, or he is an abstract class.
Iii. characteristics of abstract class members
Member variables
can have member variables
can have constants
Member Methods
There can be abstract methods
can have non-abstract methods
Construction method
You can have a constructor method, and you need to initialize the member variables of the abstract class.
Case:
Abstract class animal{
public abstract void Eat ();
}
Class Dog extends animal{
overriding abstract methods of abstract classes
public void Eat () {
System.out.println ("Dog chew Bones");
}
}
java--Abstract class