hi Shalini ,
The actual range for int is -2147483648 to 2147483647.
According to your program it is exceeding the range (Size of int).
So Implicitly type Casting is happening here.
Because of that the �a� and �b� are equal.
If you execute the following code you�ll get clear.
1 public class TestClass{
2 public static void main(String[] args) throws Exception
3 {
4 int a = Integer.MIN_VALUE;
5 int c = Integer.MAX_VALUE;
6 System.out.println("MIN_VALUE..:"+a);
7 System.out.println("MAX_VALUE..:"+c);
8 int b = -a;
9 int d=(c+1);
10 System.out.println( "a(MIN_VALUE)="+a+ ",b(-MIN_VALUE)= "+b);
11 System.out.println( "d(MAX_VALUE+1)="+d+ ",-d(MAX_VALUE+1)="+(-d));
12 }
13 }
Out put is :
MIN_VALUE..:-2147483648
MAX_VALUE..:2147483647
a(MIN_VALUE)=-2147483648 , b(-MIN_VALUE)= -2147483648
d(MAX_VALUE+1)=-2147483648 ,- d(MAX_VALUE+1)=-2147483648
In the above programs output See the MAX_VALUE(2147483647) vale and MAX_VALUE+1(-2147483648) value.
If any thing wrong with the answer Please correct me..