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 is an object oriented general purpose programming language.

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

Which of the following is not a valid datatype?

  1. A. Float
  2. B. Integer
  3. C. Binary
  4. D. Timedate
Report Error

What is the use of .capitalize method?

  1. A. It capitalizes the entire string
  2. B. It capitalize on the first letter of the string
  3. C. It capitalize the strings which are in small case
  4. D. All of the mentioned
Report Error

What is the output of the following? "Iam learning ruby language".length

  1. A. 26
  2. B. 23
  3. C. 20
  4. D. 18
Report Error

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

  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

What is the output of the following? ruby.reverse

  1. A. Error in compilation
  2. B. ybur
  3. C. 4
  4. D. Undefined local variable ruby
Report Error

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

  1. A. Amil Jones
  2. B. What's your first name? amil What's your last name? jones My name is Amil Jones
  3. C. My name is Amil jones
  4. D. None of the mentioned
Report Error

What is the output of given code? string="I'am Learning RUBY Language".downcase string.upcase

  1. A. Undefined method
  2. B. "I'AM LEARNING RUBY LANGUAGE"
  3. C. I'am Learning RUBY Language
  4. D. None of the mentioned
Report Error

What will be the output of the given code? "Come let's learn.reverse Ruby.length language".upcase

  1. A. nreal s'tel emoC 4 LANGUAGE
  2. B. Undefined error
  3. C. "COME LET'S LEARN.REVERSE RUBY.LENGTH LANGUAGE"
  4. D. None of the above
Report Error

How to comment multiple lines in ruby?

  1. A. Using multiline comments
  2. B. Using single line comments
  3. C. No option to comment
  4. D. All of the mentioned
Report Error

Why do we use comments?

  1. A. For later use to understand the working of the program
  2. B. It is an efficient way of programming
  3. C. It makes easy for the third person to understand
  4. D. All of the mentioned
Report Error

What will be the output of the given code? "I'am learning Ruby Language".reverse.upcase.length

  1. A. 27
  2. B. egaugnal ybuR gninreal ma'I
  3. C. ERAUGNAL YBUR GNINREAL MA'I
  4. D. Undefined method 'reverse' for 27:Fixnum
Report Error