ObjectiveMcq
Print Protected
This page is protected for print. Use the website to view the content.
What is the output of the given code
print "what's your first name?"
first_name=gets.chomp
a=first_name.capitalize
"first_name.capitalize!".reverse
puts"My name is #{first_name}"
Correct Answer: D — What’s your first name amil
"first_name.capitalize!".reverse reverses the string literal, not the variable. So first_name is unchanged (lowercase). The prompt is printed when code runs.