[Solved] Difference between Throw and Throws in Java- Clarification [duplicate]


Throw actually returns the exception whereas throws is a sign to the compiler, that this method could return an exception.

In your code above the exception ArithmeticException will be created and returned, if the grade is lower than 5, which is the case in your second call of QAExperience.
As the calling method called the method, which returned the exception, is not insede a catch block it will also just stop its execution and return to the main method. As the main method also does not catch the exception it will just like the others stop its execution and return the exception. This is the reason, why t.checkThrowsExp will not be executed.

2

solved Difference between Throw and Throws in Java- Clarification [duplicate]