SUMMARY polymorphic .avi 1_4_4_15_
1_4_4_16_ polymorphic .avi format using
Polymorphic implementation: references to the parent class subclass object
1_4_4_17_ used in the polymorphic characteristics member variable .avi
The following is a description of priority access, then there is no upward (parent) to find
Two ways to access member variables methodology, direct access and indirect access member variables by means of variable
Polymorphism in, if the access method where the member variables (getter / setter), subclass overwrite the parent class method, the method belongs to the subclass, the final call is subclass of
Use Laid .avi 1_4_4_18_ members polymorphic method
For multi-state members access method
Compile look left, look to the right to run
Features access:
member variables
to compile the left to see the (parent), run to the left to see the (parent)
member methods
to compile the left to see the (parent), run to the right to see (subclass). Dynamic binding
static method
to compile the left to see the (parent), run to the left to see the (parent).
(Static and class-related, not really rewrite, so the visit is to the left of)
only non-static member method, the compiler look left, look to the right to run
1_4_4_19_ benefits of using polymorphic .avi
Up 1_4_4_20_ object transformation .avi
Downcast .avi 1_4_4_21_ object
Restore will appear as abnormal failure in the operation:
Exception in thread "main" java.lang.ClassCastException: com.zyk.opp.Zi cannot be cast to com.zyk.opp.Sonmethod Zi
MethodFu
10
Here there is a problem, downcast reduction, I do not know what the prototype is how to do?
About conversion of polymorphic types can look at the following discussion
Polymorphism in a few words can explain the JAVA intuitive about it?
1_4_4_22_ with instanceof keyword .avi
Use instanceof to solve the above problems encountered prototype
Down switch must be instanceof judgment, there would be ClassCastException abnormal
1_4_4_23_ laptop USB port analysis .avi case _
1_4_4_24_ notebook case _ USB interface to achieve .avi
Manual knock code to achieve, attention,