Ruby array MCQ

11. Each element in an array is associated with _______.

A. Numbers
B. Index
C. Integer
D. None of the above

View Answer


12. Array index -1 represent ______.

A. First Element
B. Middle element
C. Last element
D. Reverse the array

View Answer


13. Which of the following command is used to tell the size of array?

A. arraynames.size
B. arraynames.length
C. arraynames.len
D. Both A and B

View Answer


14. What will be the output of the given code?

digits = Array(0..9)
num = digits.at(6)
puts #{num}

A. 5
B. 6
C. 7
D. 8

View Answer


15. What will be the output of the given code?

a = [ a, b, c ] puts a.pack(a3a3a3)

A. ABC
B. abc
C. BCD
D. bcd

View Answer


16. What will be the output of the given code?

array = [100, 200, 300, 400, 500]
print array[4]

A. [100, 200, 300, 400, 500]
B. 300
C. 400
D. 500

View Answer


17. What will be the output of the given code?

string_array = [a,e,i,o,u]
print string_array[3]

A. ["a","e","i","o","u"]
B. e
C. i
D. o

View Answer


18. What is the output of the given code?

a=[[a,b]]
b=[[e,a]]
print a + b

A. [["a", "b"], ["e", "a"]].
B. [["2a", "b"], ["e"]].
C. TRUE
D. FALSE

View Answer


19. What will be the output of the given code?

a=[1,2,3,4,5]
b=[1,2,4,6,8]
if a[3]==b[2]
    print Equal
end

A. TRUE
B. FALSE
C. Equal
D. error

View Answer


20. What is the output of the given code?

array1 = [[1,2,3,4,5],[0,0,0,0]]
print !array1

A. Error
B. [[1, 2, 3, 4, 5], [0, 0, 0, 0]].
C. TRUE
D. FALSE

View Answer





Discussion


* You must be logged in to add comment.