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 Regading Byte.MAX_VALUE 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 "Regading Byte.MAX_VALUE " Watch "Regading Byte.MAX_VALUE " New topic

Regading Byte.MAX_VALUE

Chandra Sekhar
Ranch Hand

Joined: Sep 26, 2003
Posts: 90
What is the result of the following expression ?
(byte) (Byte.MAX_VALUE + 1) == Byte.MIN_VALUE
This will print true.
Can some one help me to find the reason why it prints true.
Chandrasekhar S

"Luck is when opportunity meets preparation"
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
Byte.MAX_VALUE is 127 , that is 0x7f
Byte.MIN_VALUE is -128 , that is 0x80
0x7f + 1 = 0x80

A simple knowledge about binary, hexadecimal and two's complement is necessary for the exam. Read about them in the web or maybe just search in the Ranch

SCJP2. Please Indent your code using UBB Code
I agree. Here's the link:
subject: Regading Byte.MAX_VALUE
It's not a secret anymore!