Commerce

Basic Syntax In Ruby MCQs

Practice Basic Syntax In Ruby MCQs for competitive exams.

Basic Syntax In Ruby MCQs

Practice questions from this topic.

Ruby can deal with both numbers and floating point values.

  1. A. True
  2. B. False
Report Error

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

  1. A. Nil
  2. B. True
  3. C. False
  4. D. Error
Report Error

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

  1. A. amil jones
  2. B. What's your first name? amil My name is Amil
  3. C. My name is lima
  4. D. My name is limA
Report Error

Which of the following is not a valid library function?

  1. A. Puts
  2. B. Print
  3. C. Gets
  4. D. Get
Report Error

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

  1. A. 4 to find the length of given string
  2. B. 4
  3. C. To find the length of given string
  4. D. Ruby
Report Error

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

  1. A. Ruby
  2. B. Nil
  3. C. Error
  4. D. None of the mentioned
Report Error

What do we mean by expression substitution?

  1. A. Embedding the value of Ruby expression into a string using #{ }
  2. B. Substituting string functions
  3. C. Storing string value
  4. D. None of the mentioned
Report Error

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

  1. A. Error in compilation
  2. B. Give your address
  3. C. What's your address? Chennai Tamilnadu 600048 Iam from Chennai city, Tamilnadu state, pincode: 600048
  4. D. None of the mentioned
Report Error

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

  1. A. True
  2. B. False
Report Error

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

  1. A. Error
  2. B. Hey everyone we are learning Ruby
  3. C. Hey everyone
  4. D. Hey Everyone We are learning Ruby
Report Error

What does %Q{ Learn ruby language } represents?

  1. A. " Learn Ruby language "
  2. B. "%{ Learn Ruby language }"
  3. C. " learn ruby language "
  4. D. None of the mentioned
Report Error

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

  1. A. Error in compilation
  2. B. Name variable not defined earlier
  3. C. My name is #{Name}
  4. D. Undefined Error
Report Error