Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

1. Array of arrays are called multidimensional arrays.
a) True
b) False

View Answer

Answer: a [Reason:] We can put anything in an array and make it array of arrays.

2. 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

a) [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]].
b) [0, 0, 0, 0].
c) [0, 0, 0, 0][0, 0, 0, 0].
d) None of the mentioned

View Answer

Answer: a [Reason:] Array inside array is declared and then printed.

Output:
[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]

3. 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" }

a) [1, 2, 3, 4].
[0, 0, 0, 0].
[[1, 2, 3, 4], [0, 0, 0, 0]].
b) [0, 0, 0, 0].
c) [0, 0, 0, 0][0, 0, 0, 0].
d) None of the mentioned

View Answer

Answer: a [Reason:] Array inside array is declared and then printed and .each is the iterator used.

Output:
[1, 2, 3, 4]
[0, 0, 0, 0]
[[1, 2, 3, 4], [0, 0, 0, 0]]

4. 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

a) [[1, 2, 3, 4], [0, 0, 0, 0]].
b) Equal
c) Not equal
d) None of the mentioned

View Answer

Answer: c [Reason:] Number of elements in both the arrays are not same hence they are unequal

Output:
Not equal

5. 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

a) [[1, 2, 3, 4], [0, 0, 0, 0]].
b) Equal
c) Not equal
d) None of the mentioned

View Answer

Answer: b [Reason:] Number of elements in both the arrays are same hence they are unequal

Output:
Equal

6. 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

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) [[2,4,6,8],[0,0,0,0]].
d) None of the mentioned

View Answer

Answer: b [Reason:] By adding two arrays we mean appending those two arrays.

Output:
[[1, 2, 3, 4], [0, 0, 0, 0], [1, 2, 3, 4], [0, 0, 0, 0]]

7. 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

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) None of the mentioned

View Answer

Answer: c [Reason:] We get an empty array by subtracting two arrays of same elements

Output:
[]

8. 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

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

View Answer

Answer: d [Reason:] We can’t directly multiply elements of array, it will show an error

Output:
can't convert Array into Integer

9. 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

a) [[1, 2, 3], [0, 0, 0]].
b) [[1, 2, 3, 4], [0, 0, 0, 0], [1, 2, 3, 4], [0, 0, 0, 0]].
c) [].
d) Error

View Answer

Answer: a [Reason:] Anding two arrays will give the common elements in both the arrays.

Output:
[[1, 2, 3], [0, 0, 0]]

10. 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

a) [[1, 2, 3], [0, 0, 0]].
b) [[1, 2, 3, 4, 5], [0, 0, 0, 0]].
c) [].
d) Error

View Answer

Answer: b [Reason:] Oring two arrays will give the maximum number common and uncommon elements in both the arrays.

Output:
[[1, 2, 3, 4, 5], [0, 0, 0, 0]]

11. 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

a) [[1, 2, 3], [0, 0, 0]].
b) [[1, 2, 3, 4, 5], [0, 0, 0, 0]].
c) False
d) Error

View Answer

Answer: b [Reason:] The negation of the given array is not possible hence the result is false.

Output:
False

12. 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) False
d) Error

View Answer

Answer: a [Reason:] ‘+’ will append both the arrays.

Output:
[["a", "b"], ["e", "a"]]

Synopsis and Project Report

You can buy synopsis and project from distpub.com. Just visit https://distpub.com/product-category/projects/ and buy your university/institute project from distpub.com