What are integer overflows and underflows and how to handle
them?
Answers were Sorted based on User's Feedback
Answer / nirmala
If the specified value exceeds the range that will result
overflow.
similarly,
if the specified value below the range that will result in
underflow
ie
byte b=259;(butits rangeis(-127 to 128) totally 256
in this u will get overflow error.
| Is This Answer Correct ? | 26 Yes | 11 No |
It uses those low order bytes of the result that can fit
into the size of the type allowed by
the operation.
| Is This Answer Correct ? | 11 Yes | 4 No |
Answer / ramesh kumar
byte b = (byte)250;
Here I assinged the value to b more than the positive range
of byte. So, It leads to overflow and we won't get any
error in compile time or run time.
But some unexpected value will be stored into b. i.e b = -
6. This will affect your logic.
| Is This Answer Correct ? | 3 Yes | 0 No |
What is the maximum size of a string in java?
What is super?
What is JIT ?
Which is faster call by value or call by reference?
Explain about version control?
What is == mean?
why is multiple inheritance not allowed in java?
7 Answers Elementus Technologies, Huawei, Infosys,
What is difference between identifier and variable?
This is my code i have a doubt class ab implements a,b { public void add() { System.out.println("Hi") } } interface a { public void add(); } interface b { public void add(); } in this code i have two interface implemented in the class has same method.just i want to know which method of interface implemented in the class. interface a or interface b? confused me .
what is jdk1.5 features?
What is a nullable field?
What is OOPs & Why?