java-based abstract

Abstract methods: abstract is to add keywords, then remove the braces, ending direct semicolon. 
Abstract class: abstract class where the method must be abstract class job. Before you can write the abstract class.

How to use abstract classes and abstract methods: 
1. You can not create new abstract class object directly.
2. must inherit the abstract parent class with a subclass.
3. Subclasses must override the abstract parent class which covers all the abstract methods.
Overwrite (achieved): abstract subclass remove keywords abstract method, then fill the method body braces.
4. Create a subclass object for use.

 

 

 

 

note:

An abstract class may not contain abstract methods, 
as long as an abstract method where the class is abstract, you can.
Such a method is not an abstract class is abstract and can not create object directly, there use in some special scenarios.





 

 
 

Guess you like

Origin www.cnblogs.com/suitang/p/11594128.html
Recommended