extends of the class with private constructor

Viewed 55563

Suppose we have the following code:

class Test {
    private Test() {
        System.out.println("test");
    }

}

public class One extends Test {

    One() {
        System.out.println("One");
    }

    public static void main(String args[]) {

        new One();
    }
}

When we create an object One, that was originally called the parent class constructor Test(). but as Test() was private - we get an error. How much is a good example and a way out of this situation?

3 Answers
Related