What will be the output of the following program? Javaclass CustomException…

What will be the output of the following program?

Java
class CustomException extends Exception {
    public CustomException(String message) {
        super(message);
    }
}

public class Geeks {
    public static void main(String[] args) {
        try {
            throw new CustomException("Custom error occurred");
        } catch (CustomException e) {
            System.out.println(e.getMessage());
        }
    }
}


  1. A.

    Custom error occurred

  2. B.

    Runtime Exception

  3. C.

    Compilation Error

  4. D.

    No Output

Attempted by 255 students.

Sign up free to check your answer

Sign up free

Explore the full course: Isro

Loading lesson…