Abstract class
Abstract class: A class that is unclear
Abstract method: A method that is not clear
Methods feature declarations are the same, but methods have different functional bodies. 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.
define the format:
Classes that define abstract functions must also be decorated with the abstract keyword, and the class that is decorated by the abstract keyword is an abstract class.
/* abstract class, cannot instantiate object, cannot create object for the reason: if you really get new, object. Call abstract method, abstract method without a body, simply cannot run * inheriting his subclass must override the defined abstract method */ Public abstract class Develop { //abstract type public -abstract void work (); Abstract method}
Features:
1. Abstract classes and abstract methods need to be modified by abstractions. Abstract methods must be defined in an abstract class.
2. Abstract classes cannot create objects directly, because there is no point in invoking an abstract method.
3, only after overriding all abstract methods in the abstract class can the subclass create the object. Otherwise, the subclass is an abstract class.
The reason for inheriting abstract classes, more in mind, is to be more simple in the face of generic type operations.
Questions:
1, abstract class must be a parent class?
Yes, because of the constant extraction.
2 . Can there be no abstract method in an abstract class? If so, does it make sense to define the class as an abstract class? Why?
There can be no abstract method, it makes sense, and does not let others directly create the class object.
3. Abstract keywords can not and which keywords to coexist?
- 1,Private: The method subclass is not inheritable, and there is no overwrite, and abstract and private use the modified method,abstract subclass to implement this method, and the private modifier subclass simply cannot get the parent class method. Contradict each other.
java--Object-oriented advanced