MCQS (Programming Constructs & Algorithms
MCQS (Programming Constructs & Algorithms
1. In Java, which keyword is used to declare a variable that cannot be modified once
assigned?
A) const
B) final
C) immutable
D) static
Answer: B) final
A) 11
B) 16
C) 13
D) 10
Answer: C) 13
B) Selection Sort
C) Insertion Sort
D) Merge Sort
B) Selection Sort
C) Insertion Sort
D) Quicksort
Answer: D) Quicksort
6.What is the time complexity of Binary Search when applied to a sorted array of size n?
A) O(1)
B) O(log n)
C) O(n)
D) O(n^2)
Answer: B) O(log n)
B) Sorted arrays
8.In Java, which operator is used to compare two values for equality?
A) ==
B) =
C) !=
D) ===
Answer: A) ==
A) 2.3333333333333335
B) 2.0
C) 2.333333
D) 2.333333333333333
Answer: A) 2.3333333333333335
B) O(n log n)
C) O(n^2)
D) O(log n)
Answer: A) O(n)
12. Which sorting algorithm has the best average-case time complexity?
A) Bubble Sort
B) Insertion Sort
C) Merge Sort
D) Quick Sort
B) Unsorted arrays
B) Greedy algorithm
B) method
C) def
D) void
Answer: D) void
17.In Java, what is the return type of a function that doesn't return any value?
A) void
B) int
C) String
D) boolean
Answer: A) void
B) Ease of maintenance
D) Improved readability
21. When writing pseudocode for a modular function, what should be included in the
description?
A) Detailed implementation steps
B) Variable declarations
D) Syntax-specific details
B) Diamond
C) Circle
D) Parallelogram
Answer: A) Rectangle
25.Which sorting algorithm is more efficient for small arrays or nearly sorted arrays?
A) Bubble Sort
B) Insertion Sort
C) Quick Sort
D) Merge Sort
Answer: B) Insertion Sort
26.In Bubble Sort, what is the time complexity in the worst-case scenario?
A) O(n)
B) O(n log n)
C) O(n^2)
D) O(log n)
Answer: C) O(n^2)
28.Which of the following time complexities grows the fastest as the input size increases?
A) O(1)
B) O(log n)
C) O(n)
D) O(n^2)
Answer: D) O(n^2)
B) n = 0
C) n = 2
D) n = -1
Answer: B) n = 0