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