Home / CSE MCQs / Ruby Programming MCQs :: Ruby Programming Arrays, Hashes

CSE MCQs :: Ruby Programming MCQs

  1. 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
  2. A.
    [[1, 2, 3], [0, 0, 0]].
    B.
    [[1, 2, 3, 4, 5], [0, 0, 0, 0]].
    C.
    False
    D.
    Error

  3. 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]]
    print array1*array2
  4. A.
    [[1, 2, 3, 4], [0, 0, 0, 0]].
    B.
    [[1, 2, 3, 4], [0, 0, 0, 0], [1, 2, 3, 4], [0, 0, 0, 0]].
    C.
    [].
    D.
    Error

  5. 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
  6. A.
    [a","e","i","o","u"].
    B.
    Error
    C.
    c) o True False
    D.
    None of the mentioned

  7. What is 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
  8. A.
    Equal
    B.
    Error
    C.
    4
    D.
    None of the mentioned

  9. What will be the output of the following?

    array = [100, 200, 300, 400, 500]
    print array[4]
  10. A.
    400
    B.
    500
    C.
    Nil
    D.
    None of the mentioned

  11. What will be the output of the following?

    array = [100, 200, 300, 400, 500]
    print array[5]
  12. A.
    400
    B.
    500
    C.
    Nil
    D.
    None of the mentioned

  13. What will be the output of the following?

    array1 = [100, 200, 300, 400, 500]
    array2 = [1,2,3,4,5]
    if array1 == array2
    print "They are equal"
    else 
        print "Not equal"
    end
  14. A.
    They are equal
    B.
    Not equal
    C.
    Nil
    D.
    None of the mentioned

  15. 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
  16. A.
    [a","e","i","o","u"].
    B.
    Error
    C.
    o True False
    D.
    None of the mentioned

  17. 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]
  18. A.
    [a","e","i","o","u"]
    B.
    Error
    C.
    o False
    D.
    None of the mentioned

  19. What is the output of the given code?

    a=["hey", "ruby", "language"]
    b=["hey", "ruby", "language"]
    if a==b
        print "Equal"
    else
        print "Not equal"
    end
  20. A.
    Equal
    B.
    Error
    C.
    Not equal
    D.
    None of the mentioned