Vidyalelo
Ruby Programming · all questions

Arrays, Hashes and Strings in Ruby
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

78

Questions

3/4

Page

Pick an option on a question to see the right answer and solution.

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

Select an option to see the answer and solution.

What is the output of the given code?
a=[["a","b"]]
b=[["e","a"]]
print a + b

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following?
array = [100, 200, 300, 400, 500]
print array[4]

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following?
array1 = [1,2,3]
array2 = [0,0,0]
if array1 == array2
print "Equal"
else 
    print "Not equal"
end

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What is the output of the given code?
multi_d_array = [[1,2,3,4],[0,0,0,0]]
multi_d_array.each { |x| puts "#{x}\n" }

Select an option to see the answer and solution.

What will be the output of the following?
array = [100, 200, 300, 400, 500]
print "array[5]"

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What is the output of the given code?
array1 = [[1,2,3,4],[0,0,0,0]]
array2 = [[1,2,3],[0,0,0]]
print array1 && array2

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be output of the given code?
my_array = [1, 2, 3, 4]
print my_array

Select an option to see the answer and solution.

It is possible to make array of booleans.

Select an option to see the answer and solution.

It is possible to make array of booleans.

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.