Meaningless Drivel is fun!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes shift operator que. ! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "shift operator que. !" Watch "shift operator que. !" New topic

shift operator que. !

Ashok Paulraj
Ranch Hand

Joined: Jul 07, 2003
Posts: 78
I knew how to arrive at the solution for the below question but it will involve a big no. @ the end through an intensive calculation with powers of 2.
does the exam will have such questions ?
public class NegativeShift
public static void main(String[] args)
System.out.println(-3 >>> 1);4.
~ Shalini
Vicken Karaoghlanian
Ranch Hand

Joined: Jul 21, 2003
Posts: 522
Taurean, Sun does not expect from you to be a human calculator. The difficulty of the question is determined by its choices.
The question you posted may have smart multiple choices, for example; we all know that the output is
0111 1111 1111 1111 1111 1111 1111 1110
Correct choices may include:
1) Integer.MAX_VALUE - 1
3) (2^31) - 2

Hope this helps.

- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. - What truth? - That there is no spoon!!!
I agree. Here's the link:
subject: shift operator que. !
It's not a secret anymore!