31. What is the difference between a class method and an instance method in Ruby? A. Class methods are called on the class itself, while instance methods are called on instances of the class B. Instance methods are called on the class itself, while class methods are called on instances of the class C. Class methods are public, while instance methods are private D. Instance methods are public, while class methods are private 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
32. Which keyword is used to define a private method in a Ruby class? A. private B. def private C. def method.private D. private def 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
33. What is the purpose of the initialize method in Ruby classes? A. To set initial values for instance variables B. To define class 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
34. What does the `protected` keyword do in Ruby classes? A. Makes methods accessible only within the class and its subclasses B. Makes methods accessible only within the class C. Makes methods accessible only from outside the class D. Makes methods accessible from anywhere in the code 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
35. In Ruby, what is the purpose of the `super` keyword when used in a method? A. Calls the same method in the superclass B. Calls the same method in the subclass C. Calls a method with the same name D. Calls a method in a different class 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
36. What is the purpose of the `include` keyword in Ruby classes? A. To mix in methods from a module into a class B. To inherit from another class C. To define a new method D. To create a new instance 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
37. What is the purpose of the `extend` keyword in Ruby classes? A. Adds methods from a module as class methods B. Adds methods from a module as instance methods C. Adds methods from a superclass D. Adds methods to the superclass 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
38. In Ruby, which method is used to define getter and setter methods for class attributes? A. attr_accessor B. get_set C. reader_writer D. attr_reader 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
39. What is the purpose of encapsulation in Ruby classes? A. To hide the internal state of an object and restrict access to it B. To expose the internal state of an object and allow unrestricted access to it 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
40. What is the purpose of inheritance in Ruby? A. To allow a class to inherit properties and behaviors from another class B. To allow multiple classes to inherit from each other C. To restrict access to certain methods D. To define private 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