The .upcase and .capitalize method are used for capitalizing the whole string.
a) True
b) False
Q.2.
What is the use of .capitalize method?
a) It capitalizes the entire string
b) It capitalize on the first letter of the string
c) It capitalize the strings which are in small case
d) All of the mentioned
Q.3.
What is the role of ! at the end of the capitalize method?
a) It is the syntax for using capitalize method
b) It modifies the value stored in the variable
c) It indicates the termination of string
d) None of the mentioned
Q.4.
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}"
a) Amil Jones
b) What’s your first name? amil
c) My name is Amil Jones
d) None of the mentioned
Q.5.
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}"
a) Amil Jones
b) What’s your first name? amil
c) What’s your first name? amil
d) None of the mentioned
Q.6.
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}"
a) amil jones
b) What’s your first name? amil
c) My name is lima
d) My name is limA
Q.7.
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}"
a) amil jones
b) What’s your first name? amil
c) My name is lima
d) My name is limA
Q.8.
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}"
a) amil jones
b) What’s your first name? amil
c) What’s your first name? amil
d) My name is limA
Q.9.
What do we mean by expression substitution?
a) Embedding the value of Ruby expression into a string using #{ }
b) Substituting string functions
c) Storing string value
d) None of the mentioned
Q.10.
What is the output of the given code?
x, y, z = 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 }."
a) 12,48,40
b) Syntax error
c) The value of x is 12.
d) None of the mentioned
Q.11.
What does %{Learn ruby language} represents?
a) “Learn Ruby language”
b) “%{Learn Ruby language}”
c) ” Learn Ruby language ”
d) None of the mentioned
Q.12.
What does %Q{ Learn ruby language } represents?
a) ” Learn Ruby language ”
b) “%{ Learn Ruby language }”
c) ” Learn Ruby language ”
d) None of the mentioned
Q.13.
What does %x!ls! represents?
a) Same as back tick command output `ls`
b) Same as ‘x’
c) Same as “xls”
d) None of the mentioned
Support mcqgeeks.com by disabling your adblocker.
Please disable the adBlock and continue. Thank you.