Object-Oriented: class: A concrete object abstract that can be abstracted to represent a class of object objects with the same characteristics and behavior: is instantiated by the class, the object is an instance of the class Java in the understanding of polymorphism to make an analogy of the father person has behavior this method, which includes several actions: Eat, sleep, walk father has three sons, three sons have inherited the father's behavior method, so three sons have to eat, sleep, walk these movements, but three sons have their own action--the big son A will play guitar, the second son B will sing, three sons C will drum ... 1.Person person = new A (); Not a parent class object that points to a subclass reference but a parent class reference to a Subclass object 2. This object cannot call subclass a specific guitar method--person.guitar (); X3. If this is the only program that is not polymorphic, remember to implement the three elements of polymorphism: Inheritance overrides the parent class reference to the Subclass object 4. After that, if you call Persion.eat (), at this point in the code's compilation phase, the Persion call is still itself eat (), not the son's. And when the program is running, is Java XXX, Persion call is the son of Eat (). This dynamic process is polymorphic. In Java, a reference to a parent class can point to either the object of the parent class or the object of the child class. However, a reference to a subclass cannot point to the object of the parent class. Reference types can also be type-cast. However, the type of conversion must have an inheritance relationship, which is to allow conversions between parent and child classes only. If you attempt to convert two types that are unrelated, a compilation error will be thrown. You can use instanceof to determine whether a reference is a specified type.
The understanding of polymorphism in Java