Ruby MCQs with answers Page - 8

Here, you will find a collection of MCQ questions on Ruby. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 828.03K Points
Coach

Q. What will be the output of the given code?

Code:
while a&&b
puts a
end
  • (A) TRUE
  • (B) FALSE
  • (C) Syntax Error
  • (D) Name Error

A

Admin • 828.03K Points
Coach

Q. What will be the output of the given code?

Code:
a=1
b=1
while a&&b
puts a+b
end
  • (A) 2
  • (B) 2 2 2 2 2
  • (C) Infinite Loop
  • (D) Syntax Error

A

Admin • 828.03K Points
Coach

Q. What will be the output of the given code?

Code:
i = 4
while i > 0 do
  print i
  i -= 1
end
  • (A) 321
  • (B) 3210
  • (C) 4321
  • (D) 43210

A

Admin • 828.03K Points
Coach

Q. String is a sequence of _________ characters.

  • (A) one
  • (B) many
  • (C) Both A and B
  • (D) None of the above

A

Admin • 828.03K Points
Coach

Q. String may consists of ..........

  • (A) Number
  • (B) letter
  • (C) Special character
  • (D) All of the above

A

Admin • 828.03K Points
Coach

Q. String are

  • (A) mutable
  • (B) unmutable
  • (C) Both A and B
  • (D) None of the above

A

Admin • 828.03K Points
Coach

Q. Double quotes and single quotes will interpolates ?

  • (A) TRUE
  • (B) FALSE
  • (C) double quotes will interpolates
  • (D) Single quotes will interpolates

A

Admin • 828.03K Points
Coach

Q. what will be output for the following code?

Code:
str1 = LFC puts "str1: #{str1}"
  • (A) str1: LFC
  • (B) str1: #{str1}
  • (C) str1: {LFC}
  • (D) str1: #{LFC}

A

Admin • 828.03K Points
Coach

Q. In ruby, User can access the string elements by using the__________?

  • (A) {}
  • (B) []
  • (C) ()
  • (D) All of the above

A

Admin • 828.03K Points
Coach

Q. Ruby arrays are ____________

  • (A) unordered
  • (B) ordered
  • (C) Both A and B
  • (D) None of the above

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ