56 lines
468 B
Java
Executable File
56 lines
468 B
Java
Executable File
/*
|
|
A
|
|
B C
|
|
D E
|
|
|
|
*/
|
|
|
|
class A {
|
|
fooA() {}
|
|
}
|
|
|
|
class B extends A {
|
|
fooB() {}
|
|
}
|
|
|
|
class C extends A {
|
|
fooC(){}
|
|
}
|
|
|
|
class D extends B {
|
|
fooD() {}
|
|
}
|
|
|
|
class E extends B {
|
|
fooE() {}
|
|
}
|
|
|
|
|
|
|
|
public class TestInheritanceAcrossLevel {
|
|
|
|
public m1(x) {
|
|
x.fooA();
|
|
return x;
|
|
}
|
|
|
|
public m2(x) {
|
|
x.fooB();
|
|
/*return x;*/
|
|
}
|
|
|
|
public m3(x) {
|
|
x.fooC();
|
|
/*return x;*/
|
|
}
|
|
|
|
public m4(x) {
|
|
x.fooD();
|
|
/*return x;*/
|
|
}
|
|
|
|
public m5(B x) {
|
|
x.fooA();
|
|
return x;
|
|
}
|
|
} |