Saturday, 20 June 2009

Java Certification Question 0010

Which of the following statements are true?
1) A byte can represent between -128 to 127
2) A byte can represent between -127 to 128
3) A byte can represent between -256 to 256
4) A char can represent between -2x2 pow 16 2 x2 pow 16 - 1


Answer :
1) A byte can represent between -128 to 127
The char type is the only unsigned type in Java and thus cannot represent a negative number.

No comments: