Public classsuperclass{ Public voidPrintA () {System.out.print ("Superclass-printa"); PRINTB (); } Public voidPrintb () {System.out.print ("Superclass-printb"); }} Public classChildClassextendssuperclass{ Public voidPrintA () {System.out.print ("Childclass-printa"); Super. PrintA (); } Public voidPrintb () {System.out.print ("Childclass-printb"); } Public Static voidMain (string[] args) {ChildClass ChildClass=NewChildClass (); Childclass.printa (); }}
View Code
Subclasses call the method of the parent class through Super.printa (), and PRINTB () is called in the parent class's PrintA (), in which case the PRINTB () method of the subclass is called.
Related issues:
Http://zhidao.baidu.com/link?url=l3eoUB_0shzLHSumCutjTi57YMtq3eGluGkqyb_kpc9pcJv4PnyVOTnfCclBWcpOVp34vZFlFPZyyAknBCDSGq
Http://www.tuicool.com/articles/QBBBfe7
Java--subclasses use super to call the method of the parent class A,a called Method B, and the subclass also override method B, then super. A () finally called the B method of the subclass