File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Dan's Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Dan Watch "Dan New topic

Dan's Question

Jarrod Legion

Joined: Dec 24, 2002
Posts: 18

What is the result of attempting to compile and run the program?
a. Prints: 0000,ffff
b. Prints: 00000000,ffffffff
c. Prints: 7fff,8000
d. Prints: 8000,7fff
e. Prints: 7fffffff,80000000
f. Prints: 80000000,7fffffff
g. Compile-time error
h. Run-time error
i. None of the above
Answer: f
Can someone please explain to me how is 80000000 calculated?
Vad Fogel
Ranch Hand

Joined: Aug 25, 2003
Posts: 504
Integer.MIN_VALUE in binary is 1000 0000 0000 0000 0000 0000 0000 0000 since int is 4 byte deep. Each 4 bits comprise one hex digit (from 0000=0 to 1111=F). So, we get 80000000. Hope this helps.
Vicken Karaoghlanian
Ranch Hand

Joined: Jul 21, 2003
Posts: 522
Decimal : -2147483648
Binary : 1000 0000 0000 0000 0000 0000 0000 0000
Hexadecimal : 8 0 0 0 0 0 0 0
As you can see every 4 bits in binary is represented by 1 bit in hex, so 1000 becomes 8 and the rest is zero as you can see.
Hope this helps.

- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. - What truth? - That there is no spoon!!!
Jarrod Legion

Joined: Dec 24, 2002
Posts: 18
Thanks Vad and Vicken.
I seriously dunno how I missed out on this brain's stuffed but got to keep going...
I agree. Here's the link:
subject: Dan's Question
It's not a secret anymore!