Vidyalelo
Ruby Programming · all questions

Operators in Ruby
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

61

Questions

3/4

Page

Pick an option on a question to see the right answer and solution.

What is the output of the given code?
counter = 1
while counter < 11
  puts counter
  counter+=1
  end

Select an option to see the answer and solution.

What is the output of the given code?
a=10
b=9
if(a>b)
    print ("a greater than b")
else 
    print "Not greater"
end

Select an option to see the answer and solution.

Boolean opeartors are also known as logical operators.

Select an option to see the answer and solution.

Which of the following is a valid assignment operator?

Select an option to see the answer and solution.

What will the following expression evaluate to?
true | | false

Select an option to see the answer and solution.

What will the following expression evaluate to?
(true && false) | | (!true)

Select an option to see the answer and solution.

What will the following expression evaluate to?
true && false

Select an option to see the answer and solution.

What is the output of the given code?
if(a==10 && b=9)
    print "true"
else
    print "false"
end

Select an option to see the answer and solution.

What is the output of the given code?
test_1 = 17 > 16
puts(test_1)
test_2 = 21 <= 30
puts(test_2)
test_3 = 9 >= 9
puts(test_3)
test_4 = -11 > 4
puts(test_4)

Select an option to see the answer and solution.

What will the following expression evaluate to?
!true && !false

Select an option to see the answer and solution.

What does the **= assignment operator do?

Select an option to see the answer and solution.

What is the output of the given code?
 a= 5
b=10
while a <10 && b<20
  puts a-b
  a+=2
  b+=2
  end

Select an option to see the answer and solution.

What is the output of the given code?
counter = 100
while counter > 0
  puts counter
  counter-=25
  end

Select an option to see the answer and solution.

What will be the output of the given code?
 boolean_1 = !true
puts boolean_1  
boolean_2 = !true && !true
puts boolean_2

Select an option to see the answer and solution.

What is the output of the given code?
a="string"
b="strings"
if(a==b)
    print ("a and b are same")
else 
    print "Not same"
end

Select an option to see the answer and solution.

What is the output of the given code?
a = 5
b=10
while a <10 && b<20
  puts a*b
  a+=2
  b+=2
  end

Select an option to see the answer and solution.

What is the output of the given code?
counter=1
if counter<=5
    puts (counter)
    counter=counter+1

Select an option to see the answer and solution.

What will the following code evaluate to?
a=9!=10

Select an option to see the answer and solution.

What will be the output of the given code?
 boolean_1 = false || -10 > -9
puts boolean_1

Select an option to see the answer and solution.

What will be the output of the given code?
 boolean_1 = (3 < 4 || false) && (false || true)
puts boolean_1

Select an option to see the answer and solution.