Q. Why do we use =begin and =end?

  • (A) To mark the start and end of multiline comment
  • (B) To comment multiple lines
  • (C) To avoid the use of # again and again
  • (D) All of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (D) All of the mentioned

Q. What is the output of the given code?
x, y, z = 12, 36, 72
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. The sum of x and y is 48. The average was 40.
  • (D) None of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (C) The value of x is 12. The sum of x and y is 48. The average was 40.

Q. 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 My name is Amil
  • (C) What's your first name? amil My name is limA
  • (D) My name is limA
πŸ’¬ Discuss
βœ… Correct Answer: (B) What's your first name? amil My name is Amil

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

  • (A) Error, no output
  • (B) Ruby is an oop language
  • (C) Warning:already initialized constant Ans
  • (D) None of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (B) Ruby is an oop language

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

  • (A) Bignum
  • (B) Octal
  • (C) Fixnum
  • (D) Binary
πŸ’¬ Discuss
βœ… Correct Answer: (C) Fixnum

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

  • (A) Ruby
  • (B) Nil
  • (C) Error
  • (D) None of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (C) Error

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

  • (A) 4 to find the length of given string
  • (B) 4
  • (C) To find the length of given string
  • (D) Ruby
πŸ’¬ Discuss
βœ… Correct Answer: (B) 4

Q. Which of the following is not a valid library function?

  • (A) Puts
  • (B) Print
  • (C) Gets
  • (D) Get
πŸ’¬ Discuss
βœ… Correct Answer: (D) Get

Q. 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 My name is Amil
  • (C) My name is lima
  • (D) My name is limA
πŸ’¬ Discuss
βœ… Correct Answer: (B) What's your first name? amil My name is Amil

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

  • (A) Nil
  • (B) True
  • (C) False
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (B) True