Take as many assements as you can to improve your validate your skill rating
Total Questions: 20
1. What is the output of the code?
print "What's your first name?"
first_name=gets.chomp
a=first_name.capitalize
first_name.capitalize!
print "What's your last name?"
last_name=gets.chomp
b=last_name.capitalize
last_name.capitalize!
puts "My name is #{first_name} #{last_name}"
Correct Answer is : What’s your first name? amil
2. What is the output of the code?
print "What's your first name?"
first_name=gets.chomp
a=first_name.capitalize
first_name.capitalize!
print "What's your last name?"
last_name=gets.chomp
b=last_name.capitalize
last_name.capitalize
puts "My name is #{first_name} #{last_name}"
Correct Answer is : What’s your first name? amil
3. 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 is : What’s your first name? amil
4. What is the output of the given code?
print "what's your first name?"
first_name=gets.chomp
a=first_name.capitalize
"a".reverse
puts"My name is #{a}"
Correct Answer is : What’s your first name? amil
5. What is the output of the given code?
print "What's your first name?"
first_name=gets.chomp
a=first_name.capitalize
a=a.reverse
puts"My name is #{a}"
Correct Answer is : What’s your first name? amil
6. What do we mean by expression substitution?
Correct Answer is : Embedding the value of Ruby expression into a string using #{ }
7. What is the output of the given code?
x, y, z = 12, 36, 72
puts "The value of x is #{ x }."
puts "The sum of x and y is #{ x + y }."
puts "The average was #{ (x + y + z)/3 }."
Correct Answer is : The value of x is 12.
8. What does %{Learn ruby language} represents?
Correct Answer is : “Learn Ruby language”
9. What does %Q{ Learn ruby language } represents?
Correct Answer is : ” Learn Ruby language ”
10. What does %x!ls! represents?
Correct Answer is : Same as back tick command output `ls`
11. It is possible to make array of booleans.
Correct Answer is : TRUE
12. What is the output of the given code?
string_array = ["a","e","i","o","u"]
print string_array
Correct Answer is : [“a”,”e”,”i”,”o”,”u”].
13. What is the output of the given code?
string_array = ["a","e","i","o","u"]
print string_array[3]
Correct Answer is : o
14. What is the output of the given code?
string_array = ["a","e","i","o","u"]
boolean_array = ["True","False"]
puts string_array[3]
puts boolean_array[1]
Correct Answer is : o
15. What is the output of the given code?
a=[1,2,3,4,5]
b=[1,2,4,6,8]
if a[3]==b[2]
print "Equal"
end
Correct Answer is : Equal
16. What is the output of the given code?
a=[1,2,3,4,5]
b=[1,2,3,4,5]
if a==b
print "Equal"
else
print "Not equal"
end
Correct Answer is : Equal
17. What is the output of the given code?
a=["hey", "ruby", "language"]
b=["hey", "ruby", "language"]
if a==b
print "Equal"
else
print "Not equal"
end
Correct Answer is : Equal
18. What is the output of the given code?
a=["hey", "ruby", "language"]
b=["hey", "language", "ruby"]
if a==b
print "Equal"
else
print "Not equal"
end
Correct Answer is : Not equal
19. What is the output of the given code?
a=["hey", "ruby", "language"]
b=[1, 2, 3]
puts b[1]
puts a[2]
Correct Answer is : 2
20. Which of the following is not a valid library function?