What is the difference between
checked(a + b)
and
unchecked(a + b)
?
ClassNotFoundException, IOException, SQLException etc are the examples of the checked exceptions. I/O Exception: This Program throw I/O exception because of due FileNotFoundException is a checked exception in Java.
An unchecked exception is an exception that occurs at the time of execution. These are also called as Runtime Exceptions. These include programming bugs, such as logic errors or improper use of an API. Runtime exceptions are ignored at the time of compilation.
Those are operators that check (or do not check) for overflow in the resulting numerical operation. In the checked
case, an OverflowException
exception is raised if the result of the operation exceeds the minimum or maximum value allowed for the datatype.
More information is available from MSDN.
It controls overflow checking for integer operations.
if a + b is larger than the maximum value of the datatype, checked will throw an exception. Unchecked will roll the overflow of the value and add it to zero.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With