Computer Science, asked by ananyaverm, 8 months ago

Write a java program for user defined exception that checks the internal and external marks. If the internal mark is greater than 40, it raises the exception “Internal marks is exceed”. If the external mark is greater than 60, it raises the exception and display the message “The external marks is exceed”. Create the above exception and use it in your program.

Answers

Answered by satyamsharma21
19

Answer:

class NumberIsGreaterException extends Exception { NumberIsGreaterException() { System.out.println("User Exception "); } } public class TestMain { public static void main(String args[]) { try { int m = Integer.parseInt(args[0]); if (m > 100) { throw new NumberIsGreaterException(); } } catch (NumberIsGreaterException e) { System.out.println(e); ...

Similar questions