Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

shift operator que. !

 
Ashok Paulraj
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ranchers,
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
Posts: 522
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
2) 7FFF FFFE
3) (2^31) - 2

Hope this helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic