Let see I just built some strange structure of method extend… I want to see how much it can go with different level, where go in where go out. The entrance…
class A {
public void what() {
System.out.println("A what");
}
public void how() {
System.out.println("How first?");
}
}
class B extends A {
public void how() {
System.out.print("How second?");
super.how();
}
}
class C extends B {
public void what() {
System.out.println("C What");
}
public void why() {
System.out.println("Why you want be special leH?");
}
}
class D extends C {
public void what() {
System.out.println("D what");
}
}
class E extends D {
public void what() {
System.out.println("E what");
}
}
class ExtendMethod {
public static void main(String args[]) {
A a = new A();
a.what();
C c = new D();
c.what();
A someElse = new B();
someElse.what();
B someThingElse = new C();
someThingElse.what();
B someSpecial = new C();
//someSpecial.why();
D someThingSpecial = new E();
someThingSpecial.why();
C c2e = new E();
c2e.how();
}
}