package eclipsedbug;
class A{
int age=10;
A(){
System.out.println(age);
}
}
class B extends A{
B(){
System.out.println(20);
}
B(int b){
age=b;
System.out.println(age);
}
}
public class ExtendsDemo{
public static void main(String [] args){
B b=new B(3);
System.out.println(b.age);
System.out.println(new A().age);
}
}
运行之前自己看一下结果是什么?你答对了吗? |
|