Question 1 of 25
Hints left: 3
Q1
Which method in Ruby is used to add an element to the end of an array?
Q2
What is the output of the given code? i=1 for i in 5..10 puts i^2 end
Q3
What does the << operator do when used with a string in Ruby?
Q4
In Ruby, how do you convert a string to an array of characters?
Q5
What is the output of the given code? for num in 1..3 puts num*num m= 0 loop do m += 1 puts m break if m == 3 end end
Q6
Which method in Ruby is used to remove and return the last element of an array?
Q7
What does the 1..10 indicate?
Q8
What is the output of the given code? for num in 1..5 puts num*num end
Q9
What is the output of the given code? for num in 1...5 puts num end
Q10
What will array.size return in Ruby, if array = [1, 2, 3, 4, 5]?
Q11
What is the output of "hello".length in Ruby?
Q12
Which method is used to check if an array includes a specific element in Ruby?
Q13
What does the keys method return when called on a hash in Ruby?
Q14
Which method is used to access the value associated with a specific key in a hash in Ruby?
Q15
What is the output of "hello".reverse in Ruby?
Q16
What does the join method do when used with an array in Ruby?
Q17
What is the output of the given code? loop do m += 1 puts m break if m == 3 end
Q18
What is the output of "hello".upcase in Ruby?
Q19
What is the output of the given code? m= 0 loop do m += 1 print m break if m == 10 end
Q20
What does the 1...10 indicate?
Q21
How do you check if a key exists in a hash in Ruby?
Q22
What is the output of the given code? for num in 1..3 puts num for i in 1..2 puts num*i end end
Q23
Which of the following methods is used to merge two hashes together in Ruby?
Q24
What is the output of ["apple", "banana", "cherry"].join(", ") in Ruby?
Q25
What is the output of the given code? i=5 j=10 for i in 5..10 && j in 5..10 puts i**j end