• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Please check this qstn from Khalid Mock Exam.

 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is from Mr.Khalid's Mock Exam. I checked the answer of this qstn by cheating, just answering 1 qstn at a time and finishing the test and saw the result.
Which statements are true concerning the effect of the >> and >>> operators?
1) For non-negative values of left operand >> and >>> will have same result
2) The result of -1 >> 1 is 0
3) The result of -1 >>> 1 is -1
4) The value returned by >>> will not be -ve as long as the right operand
is equal to or greater than 1
5) When using >> operator the left most bit of the result will always be same as of the left operand
Ans given was 1) 4) 5)
I think ans shd be 1) 5) because -100>>>32 will be -100 right?
We see the last 5/6 bits of the right operand depending on the left is int/long
So we can not generalize the statement like this in ans 4)
Any input welcome.
regds
maha anna

[This message has been edited by maha anna (edited April 04, 2000).]
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're right - but see Mughal & Rasmussen's errata.
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>>> 32 will result in shifting the bit by 0 positions.
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. This qstn is put in the ErrataPage with the corrected version of the answer 4)
regds
maha anna
 
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic