Java Learning Path-inheritance (polymorphic dynamic binding)

Source: Internet
Author: User
During the dynamic binding process, the object calls the object party's execution process

1: The compiler looks at the declaration type and method name of the object. There may be multiple overloaded methods with the same method name but different parameter types.

2: The compiler looks at the type of arguments that are provided when the method is called. This procedure is called overload resolution, in the same method name has a parameter type exactly match the method, select this appropriate method. If you do not find a method that matches a parameter type, or if there is no matching method after the conversion type, an error will also be found.

3: If it is private or static or the final method or constructor, then the compiler will be able to know exactly which method to call, which is called static binding. By contrast, the method that is called relies on the actual type of the implicit parameter, and it implements dynamic binding at run time.

4: When the program runs, and when the method is called dynamically bound, the virtual machine must call the method of the class that is most appropriate for the actual type of the object referenced by x, and it is expensive to search every time the method is called. The virtual machine creates a method table in advance for each class, listing the signature of all methods and the actual method of invocation, and then directly checking a method table when the call is actually made.

Java Learning Path-inheritance (polymorphic dynamic binding)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.