编写Java应用程序包括三类:A类、B类和主类E
class A{ int a1=5;
void mA() { System.out.println("A.mA"); }
}
class B extends A {
int b1=6;
int a1=7;
void mB() { System.out.println("B.mB"); }
void mA() { System.out.println("B.mA"); }
}
public class E {
public static void main(String[] args) {
B b=new B();
A a=b;
System.out.println("b.a1="+b.a1);
System.out.println("b.b1="+b.b1);
b.mA();
b.mB();
System.out.println("a.a1="+a.a1);
a.mA();
}
}
0