(Conceptual) Why is a do-while loop generally preferred over a while loop for
displaying a user menu?
5Multiple Choice
(Scenario-Based) An algorithm's performance is O(N²). This is most likely caused by
which control structure?
6Multiple Choice
(Code-Tracing) Trace the value of sum:
int sum = 0;
for (int i = 0; i < 5; i++) {
if (i % 2 == 0) sum += i;
else if (i == 3) break;
else sum -= 1;
}
7Multiple Choice
(Conceptual) What happens when a break statement is executed inside the inner
loop of two nested loops?
8Multiple Choice
(Debugging) Look at this loop carefully. What is the outcome?
for (double i = 0.0; i != 1.0; i += 0.1) {
print(i);
}
9Multiple Choice
(Code-Tracing) What is the final value of x?
int x = 0;
while (x < 10) {
if (x < 5) x += 2;
else x += 5;
}
10Multiple Choice
(Conceptual) Which control structure is best suited for implementing a "State
Machine" where a variable can be in one of many discrete states?
11Multiple Choice
(Code-Tracing) What will be printed?
int i = 0;
for (; i < 3; i++);
print(i);
12Multiple Choice
(Comparison) What is the "Dangling Else" problem?
13Multiple Choice
(Scenario-Based) In a video game, you want a "Gravity" function to run every frame
unless the game is "Paused." Which structure is most logical?
14Multiple Choice
(Calculation) How many times will the condition in this while loop be evaluated?
int x = 0;
while (x < 5) {
x++;
}
15Multiple Choice
(Code-Tracing) Trace the output of this C++ snippet:
int n = 1;
label:
print(n);
n++;
if (n <= 3) goto label;
16Multiple Choice
(Conceptual) What is the "Short-Circuit" effect in the context of an if statement
condition?
17Multiple Choice
(Code-Tracing) Trace the output:
for (int i = 0; i < 10; i++) {
if (i % 3 == 0) continue;
if (i > 5) break;
print(i);
}
18Multiple Choice
(Debugging) Why is while(true) without a break inside usually a critical bug in a
standard desktop application?
19Multiple Choice
(Comparison) When is an if-else if chain more efficient than multiple if
statements?
20Multiple Choice
(Code-Tracing) What is the output?
int a = 10, b = 20;
int result = (a > b) ? (a + b) : (b - a);
print(result);
1Multiple Choice
(Conceptual) What happens to a function's local variables when the function finishes
executing?
2Multiple Choice
(Code-Tracing) Trace the value of n in this "Pass-by-Value" example:
void doubleVal(int x) {
x = x * 2;
}
int n = 10;
doubleVal(n);
print(n);
3Multiple Choice
(Scenario-Based) You are writing a recursive function to calculate a factorial. What is
the most important component to prevent the program from crashing?
4Multiple Choice
(Code-Tracing / Java Logic) What is the output of this snippet?
void changeList(List list) {
list.add("B");
}
List myL = new ArrayList();
myL.add("A");
changeList(myL);
print(myL.size());
5Multiple Choice
(Conceptual) Function **Overloading** is an example of which type of polymorphism?
6Multiple Choice
(Debugging) Why will the following recursive function crash for sum(3)?
int sum(int n) {
return n + sum(n - 1);
}
7Multiple Choice
(Scenario-Based) A developer wants to return two different values (a result and an
error code) from a single function in C++. What is the best modern approach?
8Multiple Choice
(Code-Tracing) Trace the value of result:
int calculate(int a, int b = 5) {
return a + b;
}
int result = calculate(10);
9Multiple Choice
(Conceptual) What is a "Pure Function" in the context of functional programming?
10Multiple Choice
(Code-Tracing) What will be printed?
int x = 50;
void doSomething() {
int x = 100;
}
doSomething();
print(x);
11Multiple Choice
(Comparison) What is the difference between a "Parameter" and an "Argument"?
12Multiple Choice
(Calculation) Trace this recursive function: f(n) = f(n-1) + f(n-2). Given
f(0)=0, f(1)=1, what is f(4)?
13Multiple Choice
(Conceptual) What does the void keyword indicate in a function signature?
14Multiple Choice
(Scenario-Based) A developer wants to pass a massive 1GB object to a function in
C++. Which method should they use to avoid slowing down the program?
15Multiple Choice
(Debugging) What is wrong with this C++ function?
int* getPointer() {
int val = 10;
return &val;
}
16Multiple Choice
(Code-Tracing) What is the output of this Python-like snippet?
def multiply(a, b):
return a * b
print(multiply(b=3, a=2))
17Multiple Choice
(Conceptual) In modern languages, what is a "Lambda" function?
18Multiple Choice
(Scenario-Based) You have a function saveData() that is called 1 million times. You
notice that the "overhead" of calling the function is slowing down the program. Which
optimization might help?
19Multiple Choice
(Code-Tracing) What is the output?
int x = 10;
void update() {
x = 20;
}
update();
print(x);
20Multiple Choice
(Conceptual) What is the "Call Stack"?
1Multiple Choice
(Conceptual) When a program needs to report a critical error that should not be mixed
with the regular program output, which standard stream should it use?
2Multiple Choice
(Code-Tracing) Trace the file handling logic in this pseudocode:
file = open("data.txt", "w")
file.write("Hello")
# System crashes here
file.close()
What is a likely real-world risk if the close() method is never reached?
3Multiple Choice
(Scenario-Based) A developer opens a log file using the mode "w" (write). The file
already contains 100 lines of logs. What happens to those 100 lines after the file is opened?
4Multiple Choice
(Conceptual) What is the main difference between reading a file in "Text" mode versus
"Binary" mode?
5Multiple Choice
(Debugging) Look at this C-style code: printf(user_input);. Why is this
considered a high-severity security vulnerability?
6Multiple Choice
(Scenario-Based) You are processing a 10GB log file on a machine with only 4GB of
RAM. What is the correct way to handle the I/O?
7Multiple Choice
(Conceptual) What does the "Flush" operation do in an I/O stream?
8Multiple Choice
(Code-Tracing) Trace the output in a language like Java or Python:
print("Apple", end="-")
print("Orange")
9Multiple Choice
(Conceptual) What is "Object Serialization"?
10Multiple Choice
(Scenario-Based) A program is stuck in a while loop reading from a network socket
because no data is arriving. This state is known as:
1Multiple Choice
(Conceptual) What is the primary reason why Strings are designed to be Immutable in
many high-level languages?
28Multiple Choice
In Java and C#, why are String objects designed to be immutable?