本帖最后由 马伟奇 于 2013-5-6 10:04 编辑
- class Father {
- int m =6;
- public Father() {
- this.show();
- }
- void show() {
- System.out.println("父");
- }
- }
- class Child1 extends Father {
- int m =10;
- void show() {
- System.out.println(m);
- }
- }
- class Child2 extends Father {
- void show() {
- System.out.println(m);
- }
- }
- class Test1 {
- public static void main(String args[]) {
- Father n = new Child1();
- Father n1 = new Child2();
- }
- }
复制代码 |