What are integer overflows and underflows and how to handle
them?

Answers were Sorted based on User's Feedback



What are integer overflows and underflows and how to handle them?..

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

What are integer overflows and underflows and how to handle them?..

Answer / ramprakash

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

What are integer overflows and underflows and how to handle them?..

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

Post New Answer

More Core Java Interview Questions

Difference between Superclass and Subclass?

7 Answers  


Is 0 true or is 1 true?

0 Answers  


What is public static?

0 Answers  


Write java code to print "Hello how are you" Thread1 should have "Hello" Thread2 should have "how are you" both the threads should start at the same time

4 Answers   Huawei,


What is the synchronized method modifier?

0 Answers  






Explain the difference between scrollbar and scrollpane?

1 Answers  


Can we override constructors in java?

0 Answers  


What is unicode used for?

0 Answers  


Write down program for following scenario. Use java coding standard. You have array list with some words in it..we will call it as dictionary….and you have a arbitrary string containing some chars in it. You have to go through each word of dictionary and find out if that word can be constructed with the help of chars from arbitrary string given. If you find the word print it else print none.

0 Answers   Rolta,


Explain the difference between throw and throws in java?

0 Answers  


Java violates few objected oriented concepts. Can you explain in what way?

3 Answers   Ness Technologies,


Can a static member function access member variable of an object?

0 Answers   Virtusa,


Categories