Computer

Arrays, Hashes And Strings In Ruby MCQs

Practice Arrays, Hashes And Strings In Ruby MCQs for competitive exams.

Arrays, Hashes And Strings In Ruby MCQs

Practice questions from this topic.

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

  1. A. [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]].
  2. B. [0, 0, 0, 0].
  3. C. [0, 0, 0, 0][0, 0, 0, 0].
  4. D. None of the mentioned
Report Error

Each element in an array has an index and the starting index is index 1.

  1. A. True
  2. B. False
Report Error

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

  1. A. [[1, 2, 3, 4], [0, 0, 0, 0]].
  2. B. Equal
  3. C. Not equal
  4. D. None of the mentioned
Report Error

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

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

What is the output of the given code? string_array = ["a","e","i","o","u"] print string_array

  1. A. ["a","e","i","o","u"].
  2. B. Error
  3. C. Vowels
  4. D. None of the mentioned
Report Error

What is the output of the given code? a=["hey", "ruby", "language"] b=[1, 2, 3] puts b[1] puts a[2]

  1. A. 3 ruby
  2. B. Error
  3. C. 2 language
  4. D. None of the mentioned
Report Error

Array of arrays are called multidimensional arrays.

  1. A. True
  2. B. False
Report Error

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. A. ["a","e","i","o","u"].
  2. B. Error
  3. C. o TRUE FALSE
  4. D. None of the mentioned
Report Error

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

  1. A. Equal
  2. B. Error
  3. C. Not equal
  4. D. None of the mentioned
Report Error

What will be the output of the following? array1 = [0,0,0] array2 = [0,0,0] if array1 == array2 print "They are equal" else print "Not equal" end

  1. A. They are equal
  2. B. Not equal
  3. C. Nil
  4. D. None of the mentioned
Report Error

What is the output of the given code? a=[1,2,3,4,5] b=[1,2,3,4,5] if a==b print "Equal" else print "Not equal" end

  1. A. Equal
  2. B. Error
  3. C. Not equal
  4. D. None of the mentioned
Report Error

It is possible to make array of booleans.

  1. A. True
  2. B. False
Report Error