21. What is the purpose of the attr_accessor method in Ruby classes? A. Defines only a reader method for class attributes B. Defines only a writer method for class attributes C. Defines constructor methods for class attributes D. Defines both reader and writer methods for class attributes 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 is the primary benefit of using inheritance in Ruby? A. It promotes code reusability and reduces redundancy B. It improves code performance C. It simplifies the syntax of a program D. It enhances code modularity 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 the initialize method in Ruby classes? A. It defines instance methods B. It defines class methods C. It defines class variables D. It is automatically called when a new object is created and allows initialization of instance variables 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
24. What is the main advantage of using encapsulation in Ruby? A. It exposes the internal state of an object and allows unrestricted access B. It allows for multiple classes to inherit from each other C. It hides the internal state of an object and restricts access to it D. It allows for objects of different classes to be treated as objects of a common superclass 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 does the term "polymorphism" mean in Ruby? A. The ability to restrict access to certain methods B. The ability for objects of different classes to be treated as objects of a common superclass C. The ability to create multiple instances of a class D. The ability to restrict access to certain methods 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
26. What does the include keyword do in Ruby? A. Creates a new instance B. Defines a new method C. Mixes in methods from a module into a class D. Inherits from another class 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