When the same functionality appears in multiple classes, but the functional body is different,
This is available for upward extraction. At this point, only the function definition is extracted, not the functional body.
Abstract: Can not understand.
Features of abstract classes:
1, the abstract method must be in the abstract class.
2, both abstract methods and abstract classes must be decorated with the abstract keyword.
3, abstract classes can not create objects with new. Because it doesn't make sense to invoke an abstract method.
4, abstract methods in the abstract class to be used, the subclass must be replicated all the abstract methods, the child class object call.
If a subclass overrides only a subset of the abstract methods, then the subclass is an abstract class.
Abstract classes and general classes are not much different.
How to describe things, how to describe things, but there are some things that things do not understand.
These uncertain parts, and the function of the thing, need to be clearly present. However, the principal cannot be defined.
Represented by an abstract method.
Abstract analogies generally have multiple abstract functions. is to define an abstract method in a class.
An abstract class cannot be instantiated.
Special: Abstract methods may not be defined in a class, and this simply does not allow the class to establish an object.
The abstract keyword, and which keywords cannot coexist.
Final: A class that is final decorated cannot have subclasses. The class that is modified by the abstract must be a parent class.
Private: Abstract methods in the abstract class, not known by the class, can not be replicated.
And the abstract approach is that it needs to be replicated.
Static: If static can modify the abstract method, then even the object is saved, the direct class name is called.
But abstract methods do not make sense to run.
Overload
Overwrite (override)
Is there a constructor in an abstract class?
Yes, an abstract class is a parent class that provides the initialization of an instance to a subclass.
Abstract class STUDENTQ
{
public abstract void Studytor ();
abstract void study1 ();
void Sleep ()
{
System.out.println ("Lying Down");
}
}
Class Chongcistudent extends studentq{
void Sleep () {
System.out.println ("Lying on the ground");
}
public void Studytor () {
System.out.println ("I have implemented the abstract method of the parent class");
}
}
Class Abstractdemo
{
public static void Main (string[] args)
{
Chongcistudent C =new chongcistudent ();
C.sleep ();
New Student ();
New Basestudent (). study ();
}
}
The abstract class of Java