21. Which method is called when an object is garbage collected in Ruby? A. finalize B. destroy C. free D. initialize 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
22. What does the protected keyword do in Ruby classes? A. Allows access to methods within the class and its subclasses B. Restricts access to methods below it C. Allows access to methods from outside the class 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
23. What is the purpose of method overriding in Ruby? A. To provide a new implementation for a method in the superclass B. To hide a method from the superclass C. To create a new method in the subclass D. To provide access to 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
24. Which keyword is used to define a class method in Ruby? A. class_method B. self.method C. def self.method D. method Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
25. What is the purpose of the extend keyword in Ruby? A. Adds methods from a module as class methods B. Adds methods from a module as instance methods C. Initializes a new instance of a class D. Calls a superclass method 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 does the super keyword do in a Ruby class method? A. Calls the same method in the superclass B. Calls the same method in the subclass C. Returns the superclass D. Initializes a superclass object 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
27. What is the purpose of the private keyword in Ruby classes? A. Restricts access to methods below it B. Allows access to methods from outside the class C. Allows access to methods within the class and its subclasses 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
28. In Ruby, what is the purpose of method overloading? A. To provide multiple definitions for the same method with different parameters B. To override a method in the superclass C. To provide a new implementation for a method in the subclass D. To create 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
29. In Ruby, what is the purpose of the attr_reader method in a class? A. To define only getter methods for class attributes B. To define only setter methods for class attributes C. To define both reader and writer methods for class attributes D. To define constructor methods for class attributes 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. What is polymorphism in Ruby? A. The ability for objects of different classes to be treated as objects of a common superclass B. The ability to hide the implementation details of a class C. The ability to restrict access to certain methods D. The ability to create objects from a 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