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. Instance variables in ruby begin with?

@
#
$
&

2. Which statement is used to execute the rescue block again from the beginning after capturing the exception?

retry
raise
ensure
else

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

digits = Array(0..9)
num = digits.at(6)
puts #{num}

5
6
7
8

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

Octal
Bignum
Fixnum
Binary

5. On which platform ruby runs on ?

Windows
Mac OS
Unix
All of the above

6. What is the extension used for saving the ruby file?

.rb extension
.ruby extension
.rrb extension
.rbb extension

7. What will be output for the following code?

str = ""Hello Ruby!""
putc str

Hello Ruby!
H
R
Hello

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

for i in 1...3  
  for j in 1..3
  puts j
  end
end

1 2 1 2
0 1 2 0 1 2
1 2 3 1 2 3
1 2 3 1 2

9. Why can not we use quotation marks ("or") with boolean?

It indicates that we are talking about a string
It indicates that we are assining a value
It indicates that that we are replacing boolean data type with string data type
None of the above

10. What will be output for the following code When input number is ""!""?

def catch_and_throw(value) 
  
  puts value 
  a = readline.chomp 
  
  throw :value_e if a == ""!""
  return a 
  
end
  
catch :value_e do
  
  number = catch_and_throw(""Enter Number: "") 
end

Error
0
Nil
Infinite Loop

Results