CSE MCQs :: Ruby Programming MCQs
-
What is the output of the given code?string = gets.chompcase stringwhen string = "a"print "alphabet a"when string = "b"print "alphabet b"when string = "c"print "alphabet c"elseprint "some other alphabet"end
-
What is the output of the code?if 1>2puts "false"endelseputs "True"end
-
What is the output of the code?variable="true".reverseif variableputs "true"elseputs "false"end
-
What is the output of the given code?if !trueprint "False"elsif !true || trueprint "True"end
-
What is the output of the given code?a=trueb=falseif a && bputs "False"elsif a || bputs "True"elseputs "neither true nor false"end
- What error does the if condition gives if not terminated with end statement?
-
What is the output of the given code?if 11>2puts "Eleven is greater than two"endprint "You'r right"
-
What is the output of the given code?hungry=falseunless hungryprint "Not hungry"elseprint "Hungry"end