1. Anminal a=new Dog ("Color"); A can only access objects that are anminal
In memory a points to a dog object.
Dog D1=dog (A);//You can see the entire dog object.
References that are defined as parent classes are most flexible.
2. Dynamic binding refers to the type of object that is referenced during execution, not during compilation.
Polymorphic bindings--late binding--instead invoke the appropriate method based on the actual type.
Three conditions for polymorphic presence: 1. Inheritance, 2. Overrides, 3. The parent class reference points to the subclass object, and new is the method of which subclass the object will call.
3.Final Keywords: Final variable values cannot be changed, methods cannot be overridden, and final classes cannot be inherited.
Equivalent to const in C + +.
4. Interface: Java only supports single inheritance, interface is a special kind of abstract class, abstract class contains only the definition of constants and methods, there is no implementation of variables and methods.
public interface runner{
public static final int id=1;
public void start ();
}
Interface attribute: The property declared in the interface defaults to public static final, which can only be an abstract method.
Class Student implements runner{
public void Start () {
SYSTEM.OUT.PRINTLN ("Student is Runner");
}
}
A class can implement multiple unrelated interfaces.
Multiple unrelated classes can implement an interface.
There is polymorphism.
Java Learning---3. Object-oriented transformation, polymorphism