11. Which of the following is used to define a class method in Ruby? A. def self.method_name B. method method_name C. class method_name D. def 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
12. What is the purpose of the `attr_accessor` method in Ruby? A. Defines both reader and writer methods for instance variables B. Defines a reader method for instance variables C. Defines a writer method 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
13. In Ruby, which method is called automatically when an object is created? A. initialize B. constructor C. create 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
14. What does the def keyword signify in Ruby? A. Declares a method B. Declares a class C. Declares a variable D. Declares a module 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
15. In Ruby, which keyword is used to call a method? A. call B. method C. execute D. invoke 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
16. What does the return keyword do in Ruby methods? A. Exits the method B. Returns a value C. Jumps to the next iteration of the loop D. Resets the 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
17. What is the purpose of the initialize method in Ruby classes? A. To initialize class variables B. To define instance variables C. To define class methods D. To define instance methods 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
18. Which of the following is NOT a valid method definition syntax in Ruby? A. def method_name; end B. define method_name; end C. define_method(:method_name) { }; end D. def self.method_name; end 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
19. What is the result of calling a method in Ruby without parentheses? A. Error B. Returns nil C. Returns the method itself D. Executes the method 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
20. In Ruby, which method is used to define a getter and setter for an instance variable? A. get_set B. attr C. read_write D. instance 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