hai friends, this is a question from Maruce Green 3 could some one explain me the 4 option which is false integral Which of the following statements are true? 1) The following statement will produce a result of 1. System.out.println( -1 >>>2); 2) Performing an unsigned left shift (<<< on a negative number will always produce a negative number result 3) The following statement will produce a result of zero, System.out.println(1 >>1); 4) All the Java integral types are signed numbers
thanking u shyam integral types
Joined: Dec 20, 2001
If you take a look at the JLS §4.2.1 Integral Types and Values, you'll see that the integral types include byte, short, int, long, and char. While byte, short, int, and long are all signed types, char is an unsigned type. Therefore, because of char, the statement is false. Not ALL integral types are signed numbers.
Originally posted by kumar shyam: 2) Performing an unsigned left shift (<<< ; ) on a negative number will always produce a negative number result
One other thing that caught my eye was this statement. There's no such thing as an unsigned left shift in Java. There is only 1 left shoft operator (<< while there are two right shift operators (>> and >>> . I suppose you could call it an unsigned left shift operator as it does not guarantee that the sign of the resulting value won't change, but there is no reason to denote such a thing as there is only one left shift operator. Also, the correct lexicon for that operation is <<, not <<<.
Joined: Dec 16, 2003
hai Corey McGlone, thank u for ur kind help. u have given me the exact pt what I wanted regards shyam