Vidyalelo
Ruby Programming · all questions

Basic Syntax in Ruby
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

134

Questions

5/7

Page

Pick an option on a question to see the right answer and solution.

What is the use of .capitalize method?

Select an option to see the answer and solution.

Which of the following is not a valid datatype?

Select an option to see the answer and solution.

Ruby is an object oriented general purpose programming language.

Select an option to see the answer and solution.

What is the output of the the given code?
puts "My name is #{Name}"

Select an option to see the answer and solution.

What does %Q{ Learn ruby language } represents?

Select an option to see the answer and solution.

What is the output of the given code?
print "Hey"
   puts "Everyone!"
   print "We are learning Ruby"

Select an option to see the answer and solution.

Ruby can be embedded into Hypertext Markup Language(HTML).

Select an option to see the answer and solution.

What is the output of the given code?
print "What's your address"
    city,state,pin=gets.chomp,gets.chomp,gets.chomp
    puts "Iam from #{city} city, #{state} state, pincode: #{pin} "

Select an option to see the answer and solution.

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}"

Select an option to see the answer and solution.

What do we mean by expression substitution?

Select an option to see the answer and solution.

What is the output of the given code?
my_string=Ruby
    puts(my_string)

Select an option to see the answer and solution.

What is the output of the given code?
“Ruby”.length #to find the length of given string

Select an option to see the answer and solution.

Which of the following is not a valid library function?

Select an option to see the answer and solution.

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}"

Select an option to see the answer and solution.

What is the output of the given code?
boolean_1 = 77<78
   puts(boolean_1)

Select an option to see the answer and solution.

Ruby can deal with both numbers and floating point values.

Select an option to see the answer and solution.

It is must for Ruby to use a compiler.

Select an option to see the answer and solution.

Why is the library function 'puts'used for?

Select an option to see the answer and solution.

Ruby is a case-sensitive language.

Select an option to see the answer and solution.

What will be the output of the following?
"Ruby".reverse.upcase

Select an option to see the answer and solution.