What will be the result of attempting to complie & run the following code?
public class minval
{
public static void main(
String args[])
{
System.out.println(Math.abs(Integer.MIN_VALUE));
}
}
(a)Causes a compilation error
(b)Causes no error and the value printed on the screen is less than zero.
(c)Causes no error and the value printed on the screen is one more than the Integer.MAX_VALUE
(d)Will throw a runtime exception due to overflow - Integer.MAX_VALUE is less in magnitude than Integer.MIN_VALUE.
The result is (b).
An absolute +ve value is displayed in the case of Byte.MIN_VALUE & Short.MIN_VALUE.Why not so in the case of an int.?How does it actually work ?