File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes true/false Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "true/false" Watch "true/false" New topic
Author

true/false

Sham Grandhe
Ranch Hand

Joined: Dec 16, 2003
Posts: 73
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
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
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.


SCJP Tipline, etc.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
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 <<<.
Sham Grandhe
Ranch Hand

Joined: Dec 16, 2003
Posts: 73
hai Corey McGlone,
thank u for ur kind help. u have given me the exact pt what I wanted
regards
shyam
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: true/false