Precautions for using java polymorphism

How is java polymorphism implemented? Java's polymorphism is the same as C + +, It is through late binding or runtime binding (runtime binding). When a method referenced by an object is called, the compiler does not know whether the reference refers to the type object described when the variable is declared or the object of the subclass of the type. Therefore, the compiler cannot bind to a specific method for this call. It can only be recognized by the runtime type in Java (RTTI, runtime type identification) is bound to specific methods at runtime. The following is a specific example:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>