Note: In this part of the knowledge point to find a lot of problems have not been clear, so there may be many less detailed or even wrong understanding, ready to turn over the programming ideas to update,
Welcome to comment Exchange
When the JVM executes a code like this: New person (). SetName ("Superzhao")
It will do so a few things
Class loading
The JVM will load the class file Xxx.person with the ClassLoader.
Load (Class) {
if (class has parent) {
Load (superclass);
}
1. static domain declaration, default initialized to 0,false,null
2. Perform static domain (Assignment) and static code block (execute code block body) in order of declaration (top down order)
The two are equivalent, so the static domain that is declared after the code block cannot be used in a static code block, but can be initialized
3. Loading static methods in order of declaration
}
constructor is called (object initialization)
1. All instance domains are initialized to default values 0,false,null
2. Perform domain initialization and block initialization in the order of declaration
3. If the constructor "first row" calls a different constructor, execute the
4. Executing the constructor body
Calling methods
1. The compiler looks at the declaration type of the object and finds all of its methods with the same method name
2. Depending on the type of the parameter, it is possible to find the appropriate "most appropriate" parent method for the type conversion (upward transformation)
3. If it is a private,static,final, constructor method, then it is determined that this method (these four types of methods do not have polymorphic characteristics),
Because there is no polymorphism, it is also called static binding.
4. In other ways, use dynamic binding: The JVM is looking for the most appropriate method for the actual type of the change class.
5. Execute the call
Java class loading, invoking constructors, executing method procedures