V

Vinay Kumar • 8.55K Points
Tutor III

Q. What will be the output of the given code?

Code:
num=4>>2
puts num
  • (A) -2
  • (B) 0
  • (C) 2
  • (D) 1
  • Correct Answer - Option(D)
  • Views: 158
  • Filed under category Ruby

Explanation by: Vinay Kumar
left operands value is moved right by the number of bits specified by the right operand.So the answer is 1.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.


Question analytics