Question 1 of 25
Hints left: 3
Q1
What is the purpose of the splat operator (*) in Ruby method definitions?
Q2
Which of the following is a correct way to call a method with arguments in Ruby?
Q3
What is the output of the given code? string_array = ["a","e","i","o","u"] print string_array
Q4
What is the output of the given code? string_array = ["a","e","i","o","u"] print string_array
Q5
What is the output of the given code? a=["hey", "ruby", "language"] b=[1, 2, 3] puts b[1] puts a[2]
Q6
Each element in an array has an index and the starting index is index 1.
Q7
What is the output of the given code? array1 = [[1,2,3,4,5],[0,0,0,0]] array2 = [[1,2,3],[0,0,0]] print array1 || array2
-
A
-
B
-
C
-
D
Q8
What is the syntax for defining a method in Ruby?
Q9
What is the output of the given code? string_array = ["a","e","i","o","u"] boolean_array = ["True","False"] puts string_array[3] puts boolean_array[1]
Q10
What is the output of the given code? a=["hey", "ruby", "language"] b=[1, 2, 3] puts b[1] puts a[2]
Q11
What will be the output of the following? array = [100, 200, 300, 400, 500] print array[5]
Q12
What does the attr_reader method do in Ruby?
Q13
In Ruby, what does the `yield` keyword do in a method?
Q14
What is the output of the given code? string_array = ["a","e","i","o","u"] boolean_array = ["True","False"] puts string_array[3] puts boolean_array
Q15
What is the output of the given code? multi_d_array = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]] print multi_d_array
-
A
-
B
-
C
-
D
Q16
What is the purpose of the `attr_accessor` method in Ruby?
Q17
What does the `super` keyword do when called inside a method in Ruby?
Q18
What is the output of the given code? array1 = [[1,2,3,4],[0,0,0,0]] array2 = [[1,2,3,4],[0,0,0,0]] if array1==array2 print "Equal" else print "Not equal" end
Q19
Which keyword is used to call a method in Ruby?
Q20
What does the return keyword do in Ruby methods?
Q21
Array of arrays are called multidimensional arrays.
Q22
In Ruby, what does the private keyword do when used in a class?
Q23
What is the output of the given code? a=["hey", "ruby", "language"] b=["hey", "language", "ruby"] if a==b print "Equal" else print "Not equal" end
Q24
Which of the following is used to define a class method in Ruby?
Q25
In Ruby, how do you define default parameter values for a method?