Your own demo---announce that you can begin to be free in the Java world.

Source: Internet
Author: User

1  Package$Interface;2 3  Public InterfaceIleavehome {4      Public Abstract inta ();5      Public Abstract intb ();6      Public Abstract intc ();7      Public Abstract intd ();8 9}
1  Package$Interface;2 3  Public Abstract classAbstracttools {4     PrivateString abs01;//Private to set the accessor, the external only can access5     PrivateString Abs02;6      Publicabstracttools (String abs01,string abs02)7     {8          This. abs01=abs01;9          This. abs02=Abs02;Ten     } One      A      Public voidtools1 () { -System.out.println ("ZZW abstract"); -     } the      Public Abstract inttool2 (); -      -      -      Public voidsetAbs01 (String abs01) +     { -          This. abs01=abs01; +     } A      PublicString getAbs01 () at     { -         returnabs01; -     } -      Public voidsetAbs02 (String abs02) -     { -          This. abs02=Abs02; in     } -      PublicString getAbs02 () to     { +         returnAbs02; -     } the}
1  Package$Interface;2 3  Public classLeavehomeimplextendsAbstracttoolsImplementsileavehome{4     5 6      PublicLeavehomeimpl (String a,string b) {7         Super(A, B);//calling the parent class's constructor method8         9         Ten     } One      Public inttool2 () { A         inta=6666;  -         returnA; -          the     } -      Public intA () { -         intA=1; -         returnA; +     } -      Public intB () { +         intB=1; A         returnb; at     } -      Public intC () { -         intC=1; -         returnC; -     } -      Public intd () { in         intD=1; -         returnD; to     } +  -      Public Static voidMain (String args[]) the     { *String z= "Z"; $String z6= "Z6";Panax NotoginsengLeavehomeimpl home=NewLeavehomeimpl (Z,Z6); -System.out.println ("home.a () =" +home.a ()); theSystem.out.println ("home.b () =" +home.b ()); +System.out.println ("home.c () =" +home.c ()); ASystem.out.println ("home.d () =" +HOME.D ());  theSystem.out.println ("home.tool2 () =" +home.tool2 ()); +System.out.println ("getabs01=" +home.getabs01 ()); -System.out.println ("getabs02=" +HOME.GETABS02 ()); $ home.tools1 (); $          -     } -      the  -}
1  Package$Interface;2 3  Public classLeavehometwiceextendsleavehomeimpl{4 String A;5 String B;6 7      PublicLeavehometwice () {//the first form of construction,8         9         Super("A", "B");//The parameter constructor of the parent class is automatically called when the value is passed in.Ten          One     } A      PublicLeavehometwice (String a,string b) {//The construction method with parameters embodies the overload of the construction method and the overloading of the construction method. -          -         Super(A, B);//changed the value of the parent class the          -     } -     //Override of method, override of method, overwrite of parent class -      Public intTool2 (inta) { +          -         intZZW; +zzw=A; A         returnZZW; at          -     } -      -      Public Static voidMain (String args[]) -     { -         intNum=123; inLeavehometwice a=NewLeavehometwice ();//corresponds to the first construction method -         //leavehometwice a=new leavehometwice ("Zzwtwice", "Aiguotwice");//corresponds to the second construction method toSystem.out.println (A.A () + "\ T" +a.b () + "\ T" +a.c () + "\ T" +A.D () + "\ T" +a.tool2 (num)); +          -          the a.tools1 (); *System.out.println ("getAbs01:" +a.getabs01 ()); $System.out.println ("GETABS02:" +A.GETABS02 ());Panax Notoginseng      -          the     } +  A}

Your own demo---announce that you can begin to be free in the Java world.

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.