1. What is the syntax for defining a method in Ruby? A. def method_name B. method method_name C. function method_name D. define 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
2. Which keyword is used to call a method in Ruby? A. call B. method C. invoke D. none of the above 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
3. What does the return keyword do in Ruby methods? A. Exits the method B. Continues the method C. Restarts the method D. None of the above 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
4. In Ruby, how do you define default parameter values for a method? A. def method(param = value) B. def method(param: value) C. def method(param = default) D. def method(param => value) 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
5. What does the attr_reader method do in Ruby? A. Defines a reader method for instance variables B. Defines a writer method for instance variables C. Defines both reader and writer methods for instance variables D. None of the above 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
6. Which of the following is a correct way to call a method with arguments in Ruby? A. method_name(arguments) B. method_name.arguments C. method_name(arguments) D. None of the above 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
7. What is the purpose of the splat operator (*) in Ruby method definitions? A. To accept a variable number of arguments B. To multiply two numbers C. To access instance variables D. None of the above 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
8. In Ruby, what does the private keyword do when used in a class? A. Restricts access to methods below it B. Allows access to methods below it C. Makes all methods public D. None of the above 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
9. In Ruby, what does the `yield` keyword do in a method? A. Exits the method B. Calls the block passed to the method C. Raises an exception 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
10. What does the `super` keyword do when called inside a method in Ruby? A. Calls the superclass method with the same name B. Calls the subclass method with the same name C. Calls the method again recursively D. None of the above 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