Welcome to your RUBY Programming MCQ
1.
How do you access a value in a hash by key in Ruby?
How do you access a value in a hash by key in Ruby?
2.
How do you access instance variables in Ruby?
How do you access instance variables in Ruby?
3.
How do you create a range in Ruby?
How do you create a range in Ruby?
4.
Which method is used to add an element to an array in Ruby?
Which method is used to add an element to an array in Ruby?
5.
How do you create a hash in Ruby?
How do you create a hash in Ruby?
6.
How do you check if a number is even in Ruby?
How do you check if a number is even in Ruby?
7.
How do you concatenate two strings in Ruby?
How do you concatenate two strings in Ruby?
8.
How do you open a file for reading in Ruby?
How do you open a file for reading in Ruby?
9.
Which method is used to remove the last element from an array in Ruby?
Which method is used to remove the last element from an array in Ruby?
10.
What is the purpose of the initialize method in Ruby?
What is the purpose of the initialize method in Ruby?
11.
How do you check if a value is included in an array in Ruby?
How do you check if a value is included in an array in Ruby?
12.
How do you handle exceptions in Ruby?
How do you handle exceptions in Ruby?
13.
How do you call a method in Ruby?
How do you call a method in Ruby?
14.
How do you convert a string to uppercase in Ruby?
How do you convert a string to uppercase in Ruby?
15.
How do you read a line from a file in Ruby?
How do you read a line from a file in Ruby?
16.
How do you close a file in Ruby?
How do you close a file in Ruby?
17.
How do you find the length of a string in Ruby?
How do you find the length of a string in Ruby?
18.
How do you start an array in Ruby?
How do you start an array in Ruby?
19.
Which keyword is used to create a loop in Ruby?
Which keyword is used to create a loop in Ruby?
20.
How do you include a module in a class in Ruby?
How do you include a module in a class in Ruby?
21.
How do you define a class in Ruby?
How do you define a class in Ruby?
22.
What is the file extension for Ruby files?
What is the file extension for Ruby files?
23.
How do you comment a single line in Ruby?
How do you comment a single line in Ruby?
24.
How do you raise an exception in Ruby?
How do you raise an exception in Ruby?
25.
How do you define a method in Ruby?
How do you define a method in Ruby?
26.
What is the output of the following code: puts "Hello, World!"?
What is the output of the following code: puts "Hello, World!"?
27.
How do you break out of a loop in Ruby?
How do you break out of a loop in Ruby?
28.
How do you create a new instance of a class in Ruby?
How do you create a new instance of a class in Ruby?
29.
How do you create a module in Ruby?
How do you create a module in Ruby?
30.
How do you convert an integer to a string in Ruby?
How do you convert an integer to a string in Ruby?