JAVA programming:
WAP to create an exception ‘PayOutOfBounds’ when the basic pay paid to a clerk is less than 3000 and more than 10,000 and for the Superintendent it is less than 12,000 and greater than 15,000.
Answers
Answer:
can u teach me programming
Answer:
Explanation:
In Java we have already defined exception classes such as Arithmetic Exception, Null Pointer Exception, Array Index Out Of Bounds exception etc. These exceptions are set to trigger on different-2 conditions. For example when we divide a number by zero, this triggers Arithmetic Exception, when we try to access the array element out of its bounds then we get Array Index Out Of Bounds Exception.
We can define our own set of conditions or rules and throw an exception explicitly using throw keyword. For example, we can throw Arithmetic Exception when we divide number by 5, or any other numbers, what we need to do is just set the condition and throw any exception using throw keyword. Throw keyword can also be used for throwing custom exceptions, I have covered that in a separate tutorial, see Custom Exceptions in Java.
Please Add Me In brainltess And follow me