#1
What is a two-dimensional array?
An array that can hold multiple arrays
ExplanationTwo-dimensional arrays are arrays that can hold other arrays as elements.
#2
How do you declare a two-dimensional array in C++?
int array[rows][columns];
ExplanationIn C++, a two-dimensional array is declared with the syntax 'int array[rows][columns];'.
#3
Which of the following is true about two-dimensional arrays?
Each element in a 2D array must be of the same data type
ExplanationTwo-dimensional arrays require all elements to be of the same data type.
#4
What is the index of the element at the second row and third column in a 2D array?
(2, 3)
ExplanationThe index of the element at the second row and third column in a 2D array is (2, 3).
#5
In Java, how do you initialize a 2D array with specific values?
int[][] array = { {1, 2, 3}, {4, 5, 6} };
ExplanationIn Java, a 2D array can be initialized with specific values using curly braces for each row.
#6
What is the time complexity for accessing an element in a 2D array?
O(1)
ExplanationAccessing an element in a 2D array has a time complexity of O(1).
#7
What is the syntax for accessing an element in a 2D array in Python?
array[row][column]
ExplanationIn Python, elements of a 2D array are accessed using the syntax 'array[row][column]'.
#8
What is the primary advantage of using a two-dimensional array over a one-dimensional array?
Ability to represent tabular data
ExplanationTwo-dimensional arrays excel at representing tabular data due to their row-column structure.
#9
In C++, how can you pass a 2D array to a function?
Passing it as a pointer
ExplanationIn C++, a 2D array is typically passed to a function by passing it as a pointer.
#10
Which of the following is an example of a 2D array initialization in JavaScript?
var array = [[1, 2], [3, 4]];
ExplanationIn JavaScript, a 2D array is initialized using nested arrays, such as 'var array = [[1, 2], [3, 4]];
#11
What is the syntax for accessing an element in a two-dimensional array in Java?
array[row][column]
ExplanationIn Java, elements of a two-dimensional array are accessed using the syntax 'array[row][column]'.
#12
Which of the following is true about multi-dimensional arrays in Python?
They are implemented using built-in data types
ExplanationMulti-dimensional arrays in Python are implemented using built-in data types like lists or tuples.
#13
What is the time complexity for searching an element in a two-dimensional array using linear search?
O(n^2)
ExplanationSearching an element in a two-dimensional array using linear search has a time complexity of O(n^2).
#14
What is the syntax for declaring a two-dimensional array in JavaScript?
var array = [[], []];
ExplanationIn JavaScript, a two-dimensional array is declared using nested empty square brackets, such as 'var array = [[], []];'.
#15
Which of the following is an advantage of using a two-dimensional array over multiple one-dimensional arrays?
Ability to represent structured data
ExplanationTwo-dimensional arrays excel at representing structured data due to their row-column organization.
#16
What is the maximum number of dimensions allowed in a two-dimensional array in most programming languages?
2
ExplanationIn most programming languages, the maximum number of dimensions allowed in a two-dimensional array is 2.
#17
What is a jagged array?
An array with irregular number of elements
ExplanationA jagged array is an array whose elements are arrays of different sizes.
#18
What is the maximum number of dimensions a multi-dimensional array can have in C#?
It's unlimited
ExplanationIn C#, multi-dimensional arrays can have unlimited dimensions.
#19
Which of the following languages doesn't support multi-dimensional arrays?
Assembly language
ExplanationAssembly language doesn't support multi-dimensional arrays.
#20
What is the data structure used to represent a two-dimensional array in memory?
Array of arrays
ExplanationA two-dimensional array is typically represented in memory as an array of arrays.
#21
In which situation would you prefer using a jagged array over a multi-dimensional array?
When the number of elements in sub-arrays varies
ExplanationJagged arrays are preferred when sub-arrays have varying numbers of elements.
#22
In which language are arrays always passed by reference?
Python
ExplanationIn Python, arrays are always passed by reference.
#23
What is the primary disadvantage of using a jagged array?
Higher memory consumption
ExplanationJagged arrays typically consume more memory compared to multi-dimensional arrays.
#24
In C#, how can you initialize a 2D array with specific values?
int[,] array = new int[2, 3] { {1, 2, 3}, {4, 5, 6} };
ExplanationIn C#, a 2D array can be initialized with specific values using the 'new' keyword and specifying the dimensions and values within curly braces.
#25
What is a common application of jagged arrays?
Storing sparse data
ExplanationJagged arrays are commonly used for storing sparse data where the number of elements varies across dimensions.