Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between checked and unchecked?

What is the difference between

checked(a + b)

and

unchecked(a + b)

?

like image 888
Difference Engine Avatar asked Sep 22 '10 17:09

Difference Engine


People also ask

What is an example of a checked exception?

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.

What is an unchecked exception?

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.


3 Answers

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.

like image 80
Steve Guidi Avatar answered Sep 19 '22 18:09

Steve Guidi


It controls overflow checking for integer operations.

like image 35
Randolpho Avatar answered Sep 20 '22 18:09

Randolpho


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.

like image 21
kemiller2002 Avatar answered Sep 21 '22 18:09

kemiller2002