class Sample1 {
Sample1() {System.out.println("Sample1 const"); }
void doStuff(){System.out.println("sample1 dostuff"); }
}
class Sample2 extends Sample1 {
Sample2() {System.out.println("Sample2 const"); }
}
public class Sample3 extends Sample2 {
Sample3() {System.out.println("Sample3 const"); }
public static void main(String r[]) {
new Sample3().go();
}
void go() { super.doStuff(); }
}
The output is:
Sample1 const
Sample2 const
Sample3 const
sample1 dostuff
My doubt is that super.doStuff() should invoke Sample2 method doStuff() if present. Why has it "propagated" upwards? I thought that happened only with no-arg super() being put implicitly (if not present) as first line of constructor.