A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Head First Android
this week in the
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
It is sorta covered in the
JavaRanch Style Guide
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