Why am I getting unreported exception when the super class default constructor has a 'throws' clause?

exception, java

Solution

You have not defined a default constructor for Sub, and Super is reporting a checked exception. To fix it add this constructor to Sub:

public Sub() throws Exception {
    super();
}

Problem

I am getting unreported exception when I run the following the code My code is as shown below ``` class Super { public Super() throws Exception { System.out.println("Super Class"); } } public class Sub extends Super { public static void main(String[] args) throws Exception { Sub s = new Sub(); } } ``` following error got: Sub.java:6: unreported exception java.lang.Exception in default constructor public class Sub extends Super { 1 error

Original source