21. What is the purpose of the self keyword in Ruby? A. Refers to the current instance of the class B. Refers to the superclass of the class C. Refers to the class itself D. Refers to the class constructor 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
22. What is the significance of the attr_writer method in Ruby classes? A. Defines only reader methods for class attributes B. Defines only writer methods for class attributes C. Defines constructor methods for class attributes D. Defines only reader methods for class attributes 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
23. What does the term "inheritance" mean in Object-Oriented Programming? A. A mechanism by which a class can create multiple instances of another class B. A mechanism by which a class can hide implementation details from another class C. A mechanism by which a class can inherit properties and behaviors from another class D. A mechanism by which a class can override methods 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
24. Which concept in Object-Oriented Programming allows objects of different classes to be treated as objects of a common superclass? A. Encapsulation B. Inheritance C. Abstraction D. Polymorphism 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
25. What is the primary purpose of a constructor in a Ruby class? A. To initialize instance variables B. To define class methods C. To create new instances of the class D. To define getter and setter 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
26. In Ruby, which keyword is used to define a private method? A. private def B. def method.private C. def private D. private 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
27. What is the main advantage of using encapsulation in Object-Oriented Programming? A. It allows multiple classes to inherit from each other B. It creates multiple instances of a class C. It hides the internal state of an object and restricts access to it D. It allows 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
28. What does the term "polymorphism" refer to in Object-Oriented Programming? 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 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
29. What is the purpose of the extend keyword in Ruby? A. Calls a superclass method B. Initializes a new instance C. Adds methods from a module as class methods D. Adds methods from a module as instance methods 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
30. What is the main purpose of using abstraction in Object-Oriented Programming? A. To expose all the implementation details B. To restrict access to public methods C. To define class methods D. To hide the complex implementation details and only expose the necessary features 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