Super class, subclass, main program Execution Ultimate Step (ii)

Source: Internet
Author: User

1  class  basetest 2 {3        //Parent class Variable4        PrivateString baseName = "base";5        //parent class static variable6         Public StaticString Staticfield = "Parent class static variable";7        //Parent class static methods8         Public Static voidOrder ()9          {TenSystem.out.println ("Parent class static Method-"); OneSystem.out.println ("Staticfield:" +Staticfield); A           } -        //parent class static initial code block -            Static  the          { -System.out.println ("Parent class static initialization code block-"); -System.out.println ("Staticfield:" +Staticfield); -           } +        //initializing a block of code -           { +System.out.println ("Parent class non-static initialization code block-"); ASystem.out.println ("BaseName:" +baseName); at           } -        //constructor Function -             Publicbasetest () -            { -System.out.println ("Parent class constructor method"); - callname (); in             } -        //member Methods to             Public voidcallname () +            { -System.out.println ("Parent class Callname Method-"); theSystem.out.println ("BaseName:" +baseName); *             } $  }Panax Notoginseng  -    the   Public   class Zhuchenxu extends  basetest    + {  A      the        //main program class variables +        PrivateString zhuchenxuname = "Zhuchenxu"; -        //main program class static variable $        Private StaticString Zhuchenxufield = "Main program class static variable"; $        //main Program class static method -         Public Static voidOrder () -          { theSystem.out.println ("Main program class static Method-"); -System.out.println ("Zhuchenxufield:" +Zhuchenxufield);Wuyi           } the        //Main program class static initial code block -            Static  Wu          { -System.out.println ("Main program class static initialization code block-"); AboutSystem.out.println ("Zhuchenxufield:" +Zhuchenxufield); $           } -        //initializing a block of code -           { -System.out.println ("Main program class non-static initialization code block-"); ASystem.out.println ("Zhuchenxuname:" +zhuchenxuname); +           } the        //constructor Function -             PublicZhuchenxu () $            {    theSystem.out.println ("Main Program class construction method"); the callname (); the             } the        //member Methods -             Public voidcallname () in            { theSystem.out.println ("Main program class Callname method-"); theSystem.out.println ("Zhuchenxuname:" +zhuchenxuname); About             } the  the  the          +          Public Static voidMain (string[] args) -  the        {BayiSYSTEM.OUT.PRINTLN ("-----[[-------"); the        Zhuchenxu s = new  Zhuchenxu ();  the        basetest m = s;  -           -SYSTEM.OUT.PRINTLN ("-----[[-------"); the          the  the         } the}

The results of the operation are as follows:

Super class, subclass, main program Execution Ultimate Step (ii)

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.