Examveda

What does the attr_accessor method do in Ruby OOP?

A. Creates constructor methods

B. Creates only a writer method

C. Creates only a reader method

D. Creates both reader and writer methods for class attributes

Answer: Option D


Join The Discussion

Related Questions on Inheritance and Polymorphism in Ruby

What is polymorphism in OOP?

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