Ruby Programming Quiz


Play this quiz that will help you to excel in Ruby certification exams, placements etc. This Ruby programming quiz consist of 10 questions that you need to solve in 10 minutes. We’ve specially designed this quiz so that you can quickly acquaint to the pattern of questions you can be asked in placement drives, certification exams etc. This Ruby programming test enables you to assess your knowledge of Ruby programming.

Take the Free Practice Test



Ruby MCQs

Practice Ruby MCQ Questions, which will help you to understand Ruby Programming related concepts and also helps you to prepare for placements, interviews, competitive exams etc.

Ruby Quiz

Try Free Ruby Quiz, to start a quiz you need to login first, after login you will get start quiz button and then by clicking on that you can start quiz. You will get 10 Minutes to answer all questions.

Ruby Quiz

1. Which of the following is Exit Controlled loop?

do..while
For
Until
While

2. eql? Operator is used for?

Used to test equality within a when clause of a case statement.
if the receiver and argument have both the same type and equal values.
if the receiver and argument have the same object id.
All of the above

3. What will be output for the following code?

str2 = String.new ""LetsFindCourse""

puts str2 

LETSFINDCOURSE
letsfindcourse
Error
LetsFindCourse

4. Which will be output for the followinf code?

puts "Hello, Ruby!";

Hello, Ruby
Hello Ruby!
Hello, Ruby!
Hello Ruby

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

counter = 1
while counter < 5
  puts counter
  counter = counter + 1
end

Prints the number from 1 to 4
Prints the number from 1 to 5
Prints the number from 2 to 5
Prints the number from 2 to 4

6. Which notation is used for Octal notation?

\s
\xnn
\n
\nn

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

i = 4
while i > 0 do
  print i
  i -= 1
end

321
3210
4321
43210

8. Which of the following is correct difference between foreach and readlines?

The method readline does not return an array.
The method foreach does not return an array.
readline is associated with a block
Both A and C

9. Which of the following Ruby Pseudo Variables is used to return current line number in the source file?

_FILE_
_CURRENT_
_LINE_
None of the above

10. Which of the method is used to returns the contents of the file line by line?

IO.read
IO.foreach
IO.syswrite
IO.readlines

Results