Methods In Ruby - Study Mode

[#1] What is the syntax for defining a method in Ruby?
Correct Answer

(A) def method_name

[#2] Which keyword is used to call a method in Ruby?
Correct Answer

(D) none of the above

[#3] What does the return keyword do in Ruby methods?
Correct Answer

(A) Exits the method
(F) Returns a value

[#4] In Ruby, how do you define default parameter values for a method?
Correct Answer

(A) def method(param = value)

[#5] What does the attr_reader method do in Ruby?
Correct Answer

(A) Defines a reader method for instance variables