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.

How to comment a single line?

  1. A. Using #
  2. B. Using begin and end
  3. C. Using //
  4. D. None of the mentioned
Report Error

Methods should not be written inside double quotes.

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

Which of the following datatypes are valid in Ruby?

  1. A. Numbers
  2. B. Boolean
  3. C. String
  4. D. All of the mentioned
Report Error

What does %x!ls! represents?

  1. A. Same as back tick command output 'ls'
  2. B. Same as 'x'
  3. C. Same as "xls"
  4. D. None of the mentioned
Report Error

Which sequence can be used to substitute the value of any ruby expression in a string?

  1. A. #(expr)
  2. B. #{expr}
  3. C. #expr
  4. D. None of the mentioned
Report Error

The downcase method changes the whole string to smallcase letters.

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

The .upcase and .capitalize method are used for capitalizing the whole string.

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

What will we the output of the given code? "I'am Learning RUBY Language".downcase

  1. A. iam learning ruby language
  2. B. i'AM lEARNING ruby lANGUAGE
  3. C. "i'am learning ruby language"
  4. D. None of the mentioned
Report Error

We use semicolon or parentheses after every print or puts statement.

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

What is the output of given code? puts "what is your first name?" name=gets.chomp puts "what is your surname?" surname=gets.chomp

  1. A. Error in compilation
  2. B. What is your first name? xyz(enter any name) What is your surname? wtu(enter your surname)
  3. C. Name=xyz
  4. D. None of the mentioned
Report Error

Objects of which class does the integer from the range -2^30 to 2^(30-1) belong to?

  1. A. Bignum
  2. B. Octal
  3. C. Fixnum
  4. D. Binary
Report Error

What is the output of the given code? Ans=Ruby puts "#[Ans] is an oop language"

  1. A. Error, no output
  2. B. Ruby is an oop language
  3. C. Warning:already initialized constant Ans
  4. D. None of the mentioned
Report Error