Ruby Programming Quiz

Ruby Programming Quiz

This quiz includes 10 objective questions about the Ruby programming language, offering a multiple options format. Test your understanding of basic Ruby constructs, object-oriented programming, standard library components and their use cases.

published on April 12, 2023
1/10

What type of language is Ruby?

What type of language is Ruby?
Object-oriented, reflective, dynamic language
Low-level, procedural language
Functional programming language
2/10

Which of the following built-in classes are not core components of the Ruby library?

String
Socket
Array
3/10

Which of the following statements can be used to generate random numbers in Ruby?

Which of the following statements can be used to generate random numbers in Ruby?
Hint: 2 choices
rand(x)
rand(x..y)
random(x..y)
4/10

Which statement will access the value of the 'name' property of a Hash object in Ruby?

Which statement will access the value of the 'name' property of a Hash object in Ruby?
hash["name"]
hash[:name]
hash[name]
5/10

What keyword is used to create a loop in Ruby?

What keyword is used to create a loop in Ruby?
Hint: 2 choices
while
for
each
6/10

Which of the following methods can be used to capitalize the first letter of a String in Ruby?

Which of the following methods can be used to capitalize the first letter of a String in Ruby?
to_upper
cap_first
capitalize
7/10

What is the return value of an empty block in ruby?

What is the return value of an empty block in ruby?
nil
true
false
8/10

Which of the following classes are available in Ruby's standard library for working with files?

Which of the following classes are available in Ruby's standard library for working with files?
Hint: 2 choices
Terminal
File
Pathname
9/10

What keyword is used to define a singleton method in Ruby?

variable
def
function
10/10

What is the symbol used to denote a positive regular expression match in Ruby?

What is the symbol used to denote a positive regular expression match in Ruby?
\
%
$