今天面试题
public class A extends B {
public A(){
System.out.println("cccc");
}
public void say(){
System.out.println("hello,a");
}
}
class B{
static {
System.out.println("aaa");
}
public B() {
System.out.println("bbb");
}
public void say(){
System.out.println("hello,b");
}
}
测试类{
public static void main(String[] args) {
B b =new A();
b.say();
}
}
------解决方案--------------------
aaa
bbb
cccc
hello,a