Inherit overwrite call essays

Source: Internet
Author: User

 Public classjcfx{Static{//Static statement blocks are executed firstSystem. out. println ("PPP" ); }     Public Static voidMain (string[] args) {A AAA=NewA ();//no parameter is passed to find the corresponding parameterless structureA AA =NewA ();//no arguments are passed, so find the corresponding parameterless structure againA A =NewA101);//instantiate the value, the object A has a parameter structure to receiveb b=NewB102);//instantiation of the value, the construction method of object B receivesa.m1 ();//invocation of Member Method: Object name. Method Name ()AA.M2 ( the,123);//to instantiate the object AA inside Method M1 () Pass valueB.move ();//call the method inside object B Move ()B.M1 ();//calling a subclass to inherit a method from a parent classString i = b.addr;//here is the invocation of the member method, not the inheritanceSystem. out. println (i); String s= A.ADDR;//accessing a member method of a subclassSystem. out. println (s); System. out. println (b.id); System. out. println (b.ID);//static variable access is directly used with the class name. The variable name, which is the name of the object. Variable name, the underlying is also converted to the class name    }}classa{Static intID =1; String Addr="Shijiazhuang"; //non-parametric constructionA () { This( +);//This () call constructor method    }    //with a reference structureAintx) {System. out. println (x); }     Public voidM2 (intCintd) {System. out. println (c+"+"+d+"="+ (c+d)); }     Public voidM1 () {inti =Ten; I++; System. out. println (i); }     Public voidMove () {System. out. println ("Method" ); }}classB extends a{//Static Variables    Static intID =2; String Addr="Beijing"; B (intt) {Super ( -);//Super (argument) constructor method for calling parent classSystem. out. println (t); }     Public voidMove () {//The replication of the parent class methodSystem. out. println ("ways to replicate a parent class" ); }}

Inherit overwrite call essays

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.