Has this question ever appeared on the test?
I think most would choose the Overflow exception as the answer. This is totally unexpected behavior. There probably are many programs out there with bug related to this.
About Question enthuware.ocajp.i.v7.2.1159 :
Moderator: admin
-
- Posts: 4
- Joined: Thu Jan 09, 2014 3:21 pm
- Contact:
-
- Site Admin
- Posts: 10053
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1159 :
As mentioned in previous posts, this much detail about 1s and 2s complement is not required for the exam.
HTH,
Paul.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 39
- Joined: Sat Jul 29, 2017 1:04 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1159 :
I did not understand the explanation in programm, but i find this in the web:
is it correct?
Code: Select all
Basically, because Integer.MAX_VALUE is actually only 2147483647, so -Integer.MIN_VALUE, which would be +2147483648, actually overflows the capacity of the internal binary representation of integers. Thus, the result "loops around" back to Integer.MIN_VALUE, or -2147483648.
-
- Site Admin
- Posts: 10053
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1159 :
Yes, the explanation explains the reason why "loop around" happens.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: Google [Bot] and 34 guests