Sail E0 Webinar

MCQs

Total Questions : 10
Question 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
  1.    [[1, 2, 3], [0, 0, 0]].
  2.    [[1, 2, 3, 4, 5], [0, 0, 0, 0]].
  3.    False
  4.    Error
 Discuss Question
Answer: Option B. -> [[1, 2, 3, 4, 5], [0, 0, 0, 0]].


The negation of the given array is not possible hence the result is false.
Output:
False


Question 2. 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
  1.    Equal
  2.    Error
  3.    4
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> Equal


a[3]=4 and b[2]=4 hence it will print equal according to the given if condition.
Output:
Equal


Question 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
  1.    [[1, 2, 3, 4], [0, 0, 0, 0]].
  2.    [[1, 2, 3, 4], [0, 0, 0, 0], [1, 2, 3, 4], [0, 0, 0, 0]].
  3.    [].
  4.    Error
 Discuss Question
Answer: Option D. -> Error


We can't directly multiply elements of array, it will show an error
Output:
can't convert Array into Integer


Question 4. 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","e","i","o","u"].
  2.    Error
  3.    c) o True False
  4.    None of the mentioned
 Discuss Question
Answer: Option C. -> c) o True False


The array is a string array and the index is 3 so 'o' will be the output and then the boolean_array will get printed.
Output:
o
True
False


Question 5. What will be the output of the following?array = [100, 200, 300, 400, 500]print array[4]
  1.    400
  2.    500
  3.    Nil
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> 500


Array's index start from 0 so array[4] will give 500.
Output:
500


Question 6. What will be the output of the following?array = [100, 200, 300, 400, 500]print array[5]
  1.    400
  2.    500
  3.    Nil
  4.    None of the mentioned
 Discuss Question
Answer: Option C. -> Nil


Array's index start from 0 so array[5] will give nothing.
Output:
Nil


Question 7. 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","e","i","o","u"].
  2.    Error
  3.    o True False
  4.    None of the mentioned
 Discuss Question
Answer: Option C. -> o True False


The array is a string array and the index is 3 so 'o' will be the output and then the boolean_array will get printed.
Output:
o
True
False


Question 8. 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
  1.    Equal
  2.    Error
  3.    Not equal
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> Equal


Elements of both the array are same and in same sequence hence they are equal.
Output:
Equal


Question 9. 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]
  1.    [a","e","i","o","u"]
  2.    Error
  3.    o False
  4.    None of the mentioned
 Discuss Question
Answer: Option C. -> o False


The array is a string array and the index is 3 so 'o' will be the output and then the boolean_array[1] = false will get printed.
Output:
o
False


Question 10. What will be the output of the following?array1 = [100, 200, 300, 400, 500]array2 = [1,2,3,4,5]if array1 == array2print "They are equal"else     print "Not equal"end
  1.    They are equal
  2.    Not equal
  3.    Nil
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> Not equal


Two arrays are said to be equal if each and every element of both the arrays are equal.
Output:
Not equal


Latest Videos

Latest Test Papers