In: Computer Science
Create a java program that:
- Has a class that defines an exception
-Have that exception throw(n) in one method, and be caught and
handled in another one.
-Has a program that always continues even if incorrect data is
entered by the user
-has a minimum of 2 classes in it
class MyException extends Exception{
public MyException(String m) {
super(m);
}
}
public class ExceptionTest {
public static void main(String[] args) {
try {
testException();
}catch(Exception e) {
System.out.println(e);
}
}
private static void testException() throws
MyException{
throw new MyException("Testing my
exception");
}
}
Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me