下列代码的运行结果是?public class TestFoo {
public static void main(String[] args) {
Foo foo = new Bar();
foo.addFive();
System.out.println("value:" + foo.a);
}
}
class Bar extends Foo {
public int a;
public Bar() {
a = 8;
}
public void addFive() {
this.a += 5;
}
}
class Foo {
public int a;
public Foo() {
a = 3;
}
public void addFive() {
this.a += 5;
}
}
|
|