Class initialization in the Java inheritance Structure

Source: Internet
Author: User

Testing for beginners

I tested Java programming language design on my own yesterday. I don't quite remember the class initialization process. I reviewed it by the way.

A test question is also prepared. Distribute your email to the output. If the output is correct, the analysis is correct.

This is the foundation. The following program analyzes the result first. If the result is correct (the result is output in a white font), you are familiar with Java class initialization. If not, review it.

 

Package nie. test. extend;/** sub-constructor initialization process: * @ author dotjar * 1. parent static domain * 2. parent static block * 3. sub-static domain * 4. sub-static block * 5. parent common domain * 6. parent common block {} * 7. parent constructor * 8. sub-common domain * 9. sub-normal block {} * 10. sub-constructor */public class test {public static void main (string [] ARGs) {New son ("S ");}} class father {static protected string S = "father_static_property_string"; // 1 protected string B = "father_normal_property_string"; // 5 static {S = "O"; // 2 system. out. print ("D"); system. out. print (s) ;}{ B = "R"; // 6 system. out. print ("A"); system. out. print (B);} father () {This ("@"); system. out. print ("1"); // 8} father (string s) {system. out. print (s); // 7} class son extends father {public static string S = "son_static_property_string"; // 3 Public String B = "son_normal_property_string "; // 9 static {S = "J"; // 4 system. out. print ("T"); system. out. print (s) ;}{ B = "3"; // 10 system. out. print ("6"); system. out. print (B);} son () {system. out. print (". "); // 11} son (string s) {this (); system. out. print ("com"); // 12 }}

 

After testing your output, you can select the next line and check it.

Here:Dotjar@163.com

 

 

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.