This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes IBM mock Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "IBM mock" Watch "IBM mock" New topic
Author

IBM mock

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi all,
I got confused by the mock question:
int x1 = -1, x2 = -1; x1 = x1 >>> 31; x2 >>= 31;
what is the result:

a) x1 = -1, x2 = -1

b) x1 = 1, x2 = -1

c) x1 = 1, x2 = 1

d) x1 = 1, x2 = 0
I think none of is correct. x1=1 is correct, but x2 is not possiable to be -1, 1 or 0. For x2>>=31, the result should be 32 bits with all 1, Am I right? Please help me!
mike

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I think the answer is B. The >>> is unsigned and the >> is signed.
hemanshow
Greenhorn

Joined: Jun 26, 2000
Posts: 25
x1 is 11111111111111111111111111111111 (32 1's )
x2 is 11111111111111111111111111111111 (32 1's )
x1 = x1 >>>31
x2 >>= 31;
now:
x1 = 00000000000000000000000000000001
x2 = 11111111111111111111111111111111
>>> adds o's to left.
>> adds what was already at the most significatnt bit(1's in our case)
M I right?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: IBM mock
 
Similar Threads
equal() and hashcode()..
I need experienced replies only regarding coding standards!
quadruple
McKenzie's Mock Exam Question 13-3 on pg. 286 has wrong answers.
High dimension Monte Carlo Integration