package java2;class A{ String x; { System.out.println("---A的非靜態(tài)語(yǔ)句塊---"); } static{ System.out.println("---A的靜態(tài)語(yǔ)句塊---"); } void print(){ System.out.println("---A中不帶參數(shù)的print方法---"); } void print(String xxx){ System.out.println("---A中帶參數(shù)的print方法,參數(shù)值未xx---"); } A(String x){ ? ?this.x="軟件"; ? ?System.out.println("---A中的無(wú)參構(gòu)造方法---"); ? ? }}class B extends A{ int x; void print(int g){ } static{ System.out.println("---B的靜態(tài)語(yǔ)句塊---"); } { System.out.println("---B中的非靜態(tài)語(yǔ)句塊---"); } public B(){ x=1; System.out.println("---B的無(wú)參構(gòu)造方法---"); }}public class java2 {? ? public void main(String args[]){? ? B x=new B();? ? x.print();? ? }}
添加回答
舉報(bào)
0/150
提交
取消