What is a multi-dimensional array?
a) An array with one dimension
b) An array with more than one dimension
c) A single value
d) A collection of strings
Answer: b) An array with more than one dimension
How do you declare a two-dimensional array in C?
a) int array[];
b) int array[10][10];
c) int array[10];
d) int array[10, 10];
Answer: b) int array[10][10];
How is a two-dimensional array stored in memory?
a) As a single contiguous block of memory
b) As linked lists
c) As separate arrays
d) Randomly in memory
Answer: a) As a single contiguous block of memory
What is the index of the first element in a two-dimensional array in C?
a) [0][0]
b) [1][1]
c) [1][0]
d) [0][1]
Answer: a) [0][0]
How do you access the element in the 3rd row and 2nd column of a two-dimensional array in Java?
a) array[2][1]
b) array[3][2]
c) array[1][2]
d) array[2][3]
Answer: a) array[2][1]
What is the time complexity of accessing an element in a multi-dimensional array?
a) O(n)
b) O(log n)
c) O(1)
d) O(n^2)
Answer: c) O(1)
How do you initialize a three-dimensional array in C++ with zeros?
a) int array[3][3][3] = {0};
b) int array[3][3][3] = 0;
c) int array[3][3][3];
d) int array[3][3][3] = { {0} };
Answer: a) int array[3][3][3] = {0};
Which of the following correctly initializes a two-dimensional array in Python?
a) array = [[0 for x in range(5)] for y in range(5)]
b) array = [0][0]
c) array = [0 for x in range(5)][0 for y in range(5)]
d) array = [[0]*5]*5
Answer: a) array = [[0 for x in range(5)] for y in range(5)]
What is the output of the following code in Python? array = [[1, 2], [3, 4]]; print(array[1][0])
a) 1
b) 2
c) 3
d) 4
Answer: c) 3
Which of the following is a correct way to declare a multi-dimensional array in JavaScript?
a) var array = [[1, 2], [3, 4]];
b) var array = {1, 2, 3, 4};
c) var array = [[1, 2, 3, 4]];
d) var array = [1, [2, 3], 4];
Answer: a) var array = [[1, 2], [3, 4]];
What is the default value of elements in a multi-dimensional array of integers in Java?
a) 0
b) null
c) undefined
d) random garbage value
Answer: a) 0
How do you find the total number of elements in a two-dimensional array int array[3][4]; in C++?
a) 3 + 4
b) 3 * 4
c) sizeof(array)
d) sizeof(array) / sizeof(array[0][0])
Answer: d) sizeof(array) / sizeof(array[0][0])
Which function would you use to find the number of rows in a two-dimensional array arr in Python?
a) len(arr)
b) len(arr[0])
c) size(arr)
d) count(arr)
Answer: a) len(arr)
How do you iterate through all elements of a two-dimensional array in Java?
a) Using nested for loops
b) Using a single for loop
c) Using a while loop
d) Using the array’s length property
Answer: a) Using nested for loops
What is the result of the following code? int array[2][2] = {{1, 2}, {3, 4}}; printf(“%d”, array[1][1]);
a) 1
b) 2
c) 3
d) 4
Answer: d) 4
How do you declare a two-dimensional array with 3 rows and 4 columns in Java?
a) int[][] array = new int[3][4];
b) int[] array = new int[3][4];
c) int[][] array = new int[4][3];
d) int array[][] = new int[3][4];
Answer: a) int[][] array = new int[3][4];
Which of the following is a valid way to assign a value to an element in a three-dimensional array in C++?
a) array[1][2] = 10;
b) array[1][2][3] = 10;
c) array[1, 2, 3] = 10;
d) array[1][2][3][4] = 10;
Answer: b) array[1][2][3] = 10;
How do you access the element in the 2nd row and 3rd column of a two-dimensional array in C++?
a) array[3][2]
b) array[2][3]
c) array[2][2]
d) array[1][2]
Answer: d) array[1][2]
What is the output of the following code in C++? int array[2][2] = {{1, 2}, {3, 4}}; cout << array[0][1];
a) 1
b) 2
c) 3
d) 4
Answer: b) 2
How do you pass a multi-dimensional array to a function in C?
a) void function(int array[10][10]);
b) void function(int array[][]);
c) void function(int array);
d) void function(int *array);
Answer: a) void function(int array[10][10]);
Basic Concepts
Non-Linear Data Structures MCQs
Sorting and Searching Algorithms MCQs
- Data Structures MCQs 1
- Data Structures MCQs 2
- Data Structures MCQs 3
- Data Structures MCQs 4
- Data Structures MCQs 5
- Stacks Solved MCQs
- Queues MCQs
- pointer mcqs
- Array MCQs