Ruby MCQ Test: Ruby MCQs - Practice Questions
1. Which operator is used to concatenate two strings in Ruby?
2. What is the purpose of the 'tap' method in Ruby?
3. What is the purpose of the 'retry' keyword in Ruby?
4. How do you define a method in Ruby?
5. Which Ruby data structure is similar to an array but can contain only unique values?
6. What is Ruby?
7. What is the purpose of the 'throw' and 'catch' keywords in Ruby?
8. In Ruby, what does 'self.included(base)' method indicate in a module?
9. What is the purpose of the 'begin' and 'rescue' keywords in Ruby?
10. What does the 'super' keyword do in Ruby?
11. Which of the following is NOT a valid way to define a variable in Ruby?
12. Which keyword is used to define a conditional statement in Ruby?
13. Which method is used to check if a variable is of a certain class in Ruby?
14. In Ruby, how do you define a range from 1 to 10?
15. In Ruby, what is the difference between 'puts' and 'print'?
16. In Ruby, what is an 'if' statement used for?
17. Who created the Ruby programming language?
18. In Ruby, what is the 'elsif' keyword used for in control structures?
19. What is the Ruby operator for equality?
20. Which operator is used for the logical 'OR' operation in Ruby?
21.
22. Which method is used to convert a string to uppercase in Ruby?
23. What is the output of the code 'puts true && false' in Ruby?
24. What is the result of '5.times.map { |i| i * 2 }' in Ruby?
25. What is the Ruby convention for naming classes?
26.
27. In Ruby, what does 'nil' represent?
28. What is the purpose of the 'map' method in Ruby?
29. What is Ruby primarily known for?
30. What is the symbol used to define a class variable in Ruby?