抽象类父 { int i = 9;
void display() {
System.out.println("base");
}
}
类子扩展父{ int i = 8;
public void display() {
System.out.println("derived");
}
}
公共类 A {
public static void main(String args[]) {
Parent a1 = new Child();
a1.display(); // calls child class method
System.out.println(a1.i);// calls parent class member
}
}