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