51. What is the output of the code?
variable=true
if variable
puts "true"
else
puts "false"
end
variable=true
if variable
puts "true"
else
puts "false"
end
52. What is the output of the code?
variable="true".reverse
if variable
puts "true"
else
puts "false"
end
variable="true".reverse
if variable
puts "true"
else
puts "false"
end
53. What is the output of the code?
variable=true
if !variable
puts "true"
else
puts "false"
end
variable=true
if !variable
puts "true"
else
puts "false"
end
54. What is the output of the code?
variable="true".length
if variable
puts "true"
else
puts "false"
end
variable="true".length
if variable
puts "true"
else
puts "false"
end
55. Which of the following is valid conditional statement?
56. What is the output of given code?
counter=1
if counter<=5
puts (counter)
counter=counter+1
else
puts(counter)
counter=counter-1
end
counter=1
if counter<=5
puts (counter)
counter=counter+1
else
puts(counter)
counter=counter-1
end
57. What is the output of given code?
#counter=1
if counter<=5
puts (counter)
counter=counter+1
else
puts(counter)
counter=counter-1
end
#counter=1
if counter<=5
puts (counter)
counter=counter+1
else
puts(counter)
counter=counter-1
end
58. It is necessary that always if should come with else block?
59. Which of the following is valid conditional statement in Ruby?
60. The elsif conditional statement is written with an expression.
Read More Section(Control Structures in Ruby)
Each Section contains maximum 100 MCQs question on Control Structures in Ruby. To get more questions visit other sections.