Answer to Question #224290 in Java | JSP | JSF for Piu

Question #224290
Write a program to create your own exception types to handle situation specific to
your application.
1
Expert's answer
2021-08-12T06:18:07-0400
public class Main {
    public static void main(String[] args) {
        try {
            throw new CustomException("Alarm!");
        } catch (CustomException e) {
            System.out.println(e);
        }
        throw new MyException("");
    }
}


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


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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS