11
Which of the following methods can be used to copy an array in Java?
A)
System.copy()
B)
Arrays.copyOf()
C)
Collections.copy()
D)
System.arraycopy()
Answer & Solution
Answer: Option
D
12
What is the time complexity of searching for an element in an unsorted array?
A)
O(1)
B)
O(log n)
C)
O(n)
D)
O(n log n)
Answer & Solution
Answer: Option
C
13
Which of the following is a disadvantage of arrays?
A)
Random access
B)
Fixed size
C)
Cache friendliness
D)
Ease of use
Answer & Solution
Answer: Option
B
14
How do you declare a 2D array in Python?
A)
array = [[0]*m]*n
B)
array = array([[0]*m]*n)
C)
array = [[0 for i in range(m)] for j in range(n)]
D)
array = [0, 0, 0, 0]
Answer & Solution
Answer: Option
C
15
What is the advantage of using arrays over linked lists?
A)
Dynamic size
B)
Better cache locality
C)
Easier insertion and deletion
D)
Lower memory usage
Answer & Solution
Answer: Option
B
16
What is the time complexity of deleting an element from an array?
A)
O(1)
B)
O(n)
C)
O(log n)
D)
O(n log n)
Answer & Solution
Answer: Option
B
17
Which of the following is true about array indexes?
A)
They start from 1
B)
They can be negative
C)
They start from 0
D)
They start from a user-defined value
Answer & Solution
Answer: Option
C
18
What is the correct way to initialize an array of size 5 in Python?
A)
array = [0] * 5
B)
array = {0, 0, 0, 0, 0}
C)
array = (0, 0, 0, 0, 0)
D)
array = new array[5]
Answer & Solution
Answer: Option
A
19
How can you pass an array to a function in C?
A)
By value
B)
By reference
C)
By copying
D)
By pointer
Answer & Solution
Answer: Option
D
20
Which of the following is an advantage of using arrays?
A)
Dynamic size
B)
Random access
C)
Ease of insertion and deletion
D)
Lower memory usage
Answer & Solution
Answer: Option
B