That's the way the Bitwise complement operator ~ works. Read what JLS Section 15.15.5 Bitwise Complement Operator ~ says-
The type of the operand expression of the unary ~ operator must be a primitive integral type, or a compile-time error occurs. Unary numeric promotion (�5.6.1) is performed on the operand. The type of the unary bitwise complement expression is the promoted type of the operand. At run time, the value of the unary bitwise complement expression is the bitwise complement of the promoted value of the operand; note that, in all cases, ~x equals (-x)-1.
Hence ~(8) = -8 - 1 = -9. You can safely use this rule in the exam.
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).