21. What does the private keyword do in Ruby? A. Makes methods accessible from outside the class B. Restricts access to methods below it C. Makes methods accessible from anywhere in the code D. None of the above Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
22. Which of the following is true about optional parameters in Ruby methods? A. They must be specified during method definition B. They have default values assigned C. They are always required D. They cannot be used with block parameters Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
23. In Ruby, which method is used to check if an object responds to a certain method? A. method_defined? B. respond_to? C. has_method? D. check_method Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
24. What does the `super` keyword do in Ruby? A. Calls the method with the same name in the superclass B. Calls the method with the same name in the subclass C. Returns the superclass of the current class D. Jumps to the next iteration of the loop Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
25. What is the purpose of the `alias` keyword in Ruby? A. To create an alias for a method B. To define a new method C. To remove a method D. To call a method with a different name Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
26. What is the purpose of the yield keyword in Ruby? A. To exit a method B. To call another method C. To define a block D. To pass control and arguments to a block Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
27. Which of the following is a correct way to define a method that takes multiple arguments in Ruby? A. def method(arg1, arg2) B. def method(arg1, arg2); end C. def method(arg1 arg2); end D. def method(arg1 arg2) Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
28. In Ruby, what does the attr_reader method do? A. Defines a setter method B. Defines a getter method C. Defines both getter and setter methods D. None of the above Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
29. What is the purpose of the alias_method keyword in Ruby? A. To create an alias for a method B. To define a new method C. To remove a method D. To call a method with a different name Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
30. In Ruby, which keyword is used to define a class method? A. def self.method_name B. method method_name C. class method_name D. def class.method_name Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board