1,
Polymorphic: A reference to a parent class that points to a subclass object, has inheritance, has overrides
Polymorphic expression: Cat is a Animal
Rule: polymorphic objects cannot call methods that are not in the parent class
Definition: Animal cat = new Cat ();
2,
Interface: The class implements the interface implement, is also a kind of extremely abstract abstract class, also is the class many behavior collection
The interface expresses: cat has the capacity to jump
Rule: member non-static method is automatically public, can not have method body, can have return value, can have parameter
Member properties are automatically public final static
Methods in the interface must be implemented
Definition: 1) interface public interface doolfun{
public static float pi = 3.45f;
void alert ();
}
2) Implement Interface public class Dool implements doolfun{
@Override
void Open () {
TODO auto-generated Method Stub
System.out.println ("Open box");
}
}
3,
Abstract classes: Classes can inherit abstract class extends, which is the set of behaviors that a class unifies, and abstract classes are just a few special classes.
Abstract class expresses: cat has eat behavior
Rule: A member method can have a method body and can contain non-abstract methods, but the abstract method and the method in the interface must be implemented in a subclass, with no method body
Abstract classes can implement polymorphic
Abstract members are automatically public
Definition: 1) abstract class animals{}
2) Inherit public class Dog extends Animals
Knowledge of Java polymorphism, interfaces, abstract classes