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

2/4

Page

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

What is the result of the expression: !(true && false) in Ruby?

Select an option to see the answer and solution.

What is the output of the given code?
counter = -50
while counter <0
  puts counter
  counter+=10
  end

Select an option to see the answer and solution.

What will be the output of the given code?
 boolean_1 = 2**3 != 3**2 || true
puts boolean_1

Select an option to see the answer and solution.

Which of the following is a valid boolean operator?

Select an option to see the answer and solution.

Ruby does not support ++ operator, it only supports += operator.

Select an option to see the answer and solution.

Assignment operator is also known as relational operator.

Select an option to see the answer and solution.

The == 'is equal to' is known as relational operator.

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?
 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.

The '=' is used for assigning value to variable?

Select an option to see the answer and solution.

The given two expression means the same.
counter=counter+1 and counter++

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)&&true
  puts a*b
  a+=2
  b+=2
  end

Select an option to see the answer and solution.

The boolean operator && only result in true when both the values are true?

Select an option to see the answer and solution.

What will be the output of the given code?
 boolean_1 = !(700 / 10 == 70)
puts boolean_1

Select an option to see the answer and solution.

What will be the output of the given code?
boolean_1 = 77 < 78 && 77 < 77
puts boolean_1

Select an option to see the answer and solution.

What will be the output of the given code?
 boolean_2 = !true && (!true || 100 != 5**2)
puts boolean_2

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.

Which of the following are used for comparison?

Select an option to see the answer and solution.

What is the output of the given code?
a = 22.5
while a >11.5
  puts a
  a-=3.5
  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/=5
  end

Select an option to see the answer and solution.