Call to super needs try/catch

exception, inheritance, java

Solution

public ClassB extends ClassA {
    public ClassB() throws MyClassAException {
        super();
    }
}

Problem

I am working on an assignment where I am told that I need to create a class (Call it ClassB) that must extend a given class (Call it ClassA). The only problem is that the code inside of the constructor of ClassA may throw an exception, so when I create my constructor for ClassB, I am trying to wrap a try/catch block around the call to super(), but of course, that doesn't work since super has to be the first call. How can I work around this?

Original source