What is the difference between attr_reader, attr_writer, and attr_accessor in Ruby?
A. attr_reader defines both reader and writer methods, attr_writer defines only reader methods, and attr_accessor defines only writer methods
B. attr_reader defines both reader and writer methods, attr_writer defines only writer methods, and attr_accessor defines only reader methods
C. attr_reader defines only writer methods, attr_writer defines both reader and writer methods, and attr_accessor defines only reader methods
D. attr_reader defines only reader methods, attr_writer defines only writer methods, and attr_accessor defines both
Answer: Option D
What is encapsulation in object-oriented programming (OOP)?
A. Binding data and methods together
B. Inheriting from multiple classes
C. Exposing internal implementation details
D. Restricting access to public methods
What does inheritance allow in OOP?
A. A class to override instance methods
B. A class to access private methods
C. A class to be instantiated
D. A class to inherit properties and behaviors from another class
A. The ability to hide implementation details
B. The ability to restrict access to certain methods
C. The ability for objects of different classes to be treated as objects of a common superclass
D. The ability to create multiple instances
What is the purpose of the super keyword in Ruby OOP?
A. Returns the superclass
B. Calls the same method in the superclass
C. Initializes a superclass object
D. None of the above

Join The Discussion