Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What is the output of the given code?
length=gets.chomp
case length.reverse.length
when length=4
print “length is 4”
when length=5
print “length is 5”
end

What is the output of the given code?
length=gets.chomp
case length.reverse.length
when length=4
print “length is 4”
when length=5
print “length is 5”
end
a) ruby
length is 4
b) ruby
length is 5
c) abc
length is 4
d) syntax error

Answer: a
Explanation: The reverse method does not effect the length of the string.

Join The Discussion