Quick Test

Array and Array Operations

  • Our quick test is a 40-point assessment designed to gauge your understanding of key concepts. It features 10 multiple-choice questions.
  • Each correct answer earns you 4 points, while each wrong answer deducts 1 point.
  • Your final score determines your grade, ranging from A+ to D.
  • This test helps you identify areas of strength and areas needing improvement.

Good luck!

1. What is the index of the first element in a typical array?

a) -1

b) 0

c) 1

d) Depends on the language

2. How do you access the third element of an array named arr?

a)

arr(3)

b)

arr[2]

c)

arr[3]

d)

arr.get(3)

3. Which operation is used to add an element at the end of an array in most programming languages?

a)

push

b)

append

c)

insert

d)

add

4. What is the time complexity of accessing an element in an array?

a) O(n)

b) O(log n)

c) O(1)

d) O(n log n)

5. What is the result of the following operation in Python:

arr = [1, 2, 3]; arr[1] = 4

a)

[1, 2, 3]

b)

[1, 4, 3]

c)

[1, 3, 4]

d)

IndexError

6. Given an array arr = [2, 4, 6, 8, 10], what will be the result of the operation
arr.splice(2, 1)
in JavaScript?

a)

[2, 4, 8, 10]

b)

[4, 6, 8, 10]

c)

[2, 4, 6, 8, 10]

d)

[2, 4, 8]

7. What is the result of the following Python code snippet?

arr = [1, 2, 3, 4, 5]
arr[::2] = [9, 9, 9]

a)

[9, 2, 9, 4, 9]

b)

[9, 9, 9, 9, 9]

c)

[1, 2, 3, 4, 5]

d)

ValueError

8. What does the following C++ code snippet do?

int arr[] = {10, 20, 30, 40};
int *ptr = arr + 2;
cout << *ptr << endl;

a) Prints 10

b) Prints 20

c) Prints 30

d) Throws an error

9. Which of the following operations can be used to remove the last element of an array in JavaScript?

a)

arr.pop()

b)

arr.remove()

c)

arr.shift()

d)

arr.delete()

10. What will be the output of the following Java code?

int[] arr = {1, 2, 3, 4, 5};
System.out.println(arr.length);

a)

4

b)

5

c)

6

d)

Throws an error

Check Your Grade

Grade A+

Score Range: 35-40 points Remarks: Excellent job! You aced the test and showed a strong grasp of the material. Keep up the fantastic work!

Grade A

Score Range: 30-34 points Remarks: Great work! You did very well and demonstrated a solid understanding of the concepts. Just a little more effort and you’ll hit perfection.

Grade B

Score Range: 20-29 points Remarks: Good effort! You have a good understanding, but there’s room for improvement. Review the areas you missed and you’ll do even better next time.

Grade C

Score Range: 10-19 points Remarks: Fair attempt. You have some understanding of the material, but you need to work on several areas. Keep studying and ask for help if needed.

Grade D

Score Range: 0-9 points Remarks: Needs improvement. It seems like you had some trouble with the material. Don’t get discouraged; use this as a learning opportunity to do better next time.