A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Programmer Certification (SCJP/OCPJP)
Joined: Sep 26, 2003
Nov 03, 2003 01:15:00
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.
"Luck is when opportunity meets preparation"
Joined: Jul 03, 2001
Nov 03, 2003 01:30:00
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
Question regarding Byte.MAX_VALUE
How to predict the output for this type of Qs?
Dan's Byte.MAX_VALUE question
operator precedence and associativity
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015