ConstructorCallsOverride.java

package ch.hslu.exercises.sw09;

public final class ConstructorCallsOverride {
    private ConstructorCallsOverride() {
    }

    public static void main(final String[] args) {

        abstract class Base {
            Base() {
                overrideMe();
            }

            abstract void overrideMe();
        }

        class Child extends Base {

            private final int x;

            Child(final int x) {
                this.x = x;
            }

            @Override
            void overrideMe() {
                System.out.println(x);
            }
        }
        new Child(42); // prints "0"
    }
}