Which of the following correctly defines a custom exception?

Last Updated :
Discuss
Comments

Which of the following correctly defines a custom exception?

Java
class MyException {
    public MyException(String message) {
        super(message);
    }
}


Java
class MyException extends RuntimeException {
    public MyException(String message) {
        super(message);
    }
}


Java
class MyException extends Throwable {
    public MyException(String message) {
        super(message);
    }
}


Java
class MyException extends Error {
    public MyException(String message) {
        super(message);
    }
}


Share your thoughts in the comments