Vidyalelo
Ruby Programming · Q12

Inheritance and Polymorphism in Ruby

Programming · Ruby Programming · question 12

Q12

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

Answer: Option D

Solution

Answer: Option D
No explanation is given for this question Let's Discuss on Board