Ruby MCQ Test: Ruby MCQs - Practice Questions
1. What is the purpose of the 'throw' and 'catch' keywords in Ruby?
2. What does the 'nil' value represent in Ruby?
3. What is the result of 5 + 3 in Ruby?
4. What is the difference between '==', '===' and 'eql?' in Ruby?
5. What is the Ruby convention for naming variables?
6. In Ruby, what is the difference between 'puts' and 'print'?
7. Which method is used to remove the last element from an array in Ruby?
8.
9. What is the purpose of the 'unless' keyword in Ruby?
10. Which keyword is used to define a conditional statement in Ruby?
11. What is the purpose of the 'require' keyword in Ruby?
12. What is a Ruby symbol?
13. What is the purpose of the 'each' method in Ruby?
14. What is the output of the code 'puts true && false' in Ruby?
15. What is the purpose of the 'initialize' method in a Ruby class?
16. Which operator is used for the logical 'OR' operation in Ruby?
17. Who created the Ruby programming language?
18. What is the symbol used to define a class variable in Ruby?
19. Which Ruby operator is used to check if an object belongs to a specific class or module?
20. What is the primary use of the 'puts' method in Ruby?
21. In Ruby, what is an 'if' statement used for?
22. In Ruby, what is a lambda?
23. What is the purpose of the 'include' module in Ruby?
24. Which method is used to convert a string to uppercase in Ruby?
25. What is Ruby?
26. In Ruby, what is the 'send' method used for?
27. Which operator is used for concatenating strings in Ruby?
28. What is the purpose of the 'tap' method in Ruby?
29. Which Ruby data structure is similar to an array but allows you to associate values with keys?
30. What does the 'super' keyword do in Ruby?
31. In Ruby, what is the 'elsif' keyword used for in control structures?
32. In Ruby, how do you define a constant?
33. In Ruby, what is the purpose of the 'super' keyword in a subclass?
34. What is the purpose of the 'begin' and 'rescue' keywords in Ruby?
35. What is the purpose of the 'freeze' method in Ruby?
36. In Ruby, how do you define a range from 1 to 10?
37. What is the symbol used to represent the current object in Ruby?
38. In Ruby, what is the purpose of the 'next' keyword within a loop?
39. In Ruby, what is a 'block'?
40. Which method is used to check if a variable is of a certain class in Ruby?
41. Which of the following is NOT a valid way to define a variable in Ruby?
42. Which of the following is a valid way to define a variable in Ruby?
43. What is the Ruby operator for equality?
44. Which method is used to iterate over each element of an array in Ruby?
45.
46. What is the output of the code 'puts 2 * 3' in Ruby?
47. In Ruby, what symbol is used to define a comment that spans multiple lines?
48. What does the 'include' module function do in Ruby?
49. Which of the following is not a valid variable naming convention in Ruby?
50.