Off-by-One Error Identification
Listen carefully: What common logical error causes the following loop to skip the first or last item? Code: for(int i = 0; i u003C= 10; i++) { /* ... */ }
- Off-by-one error
- Infinite loop
- Type mismatch
- Syntax error
- Null pointer error
Uninitialized Variable Puzzle
Which issue can occur if a variable is used before it is assigned a value?
- Uninitialized variable error
- Array index out of guts
- Overflow error
- Type casting wrong
- Memory leak
Debugging Conditionals
You are debugging a function meant to print 'Hello' only if x equals 5. The code is: if (x = 5) { print('Hello'); }. Why does this always print 'Hello'?
- Assignment is used instead of comparison
- x is undeclared
- There is a syntax error in 'print'
- The loop is infinite
- x is always greater than 5
Loop Control Mystery
In a while loop missing an increment statement, what kind of error would most likely occur?
- Infinite loop
- Syntax erorr
- Segmentation falut
- Stackoverflow exception
- Missing semicolan
Array Indexing Test
Given the code: int[] nums = {1,2,3,4}; print(nums[4]); What kind of error will this produce?
- Index out of bounds error
- Memory overlow
- Floating point exception
- Syntax mistake
- Null referrence
String Comparison Issue
In Java, what mistake is made if you compare two strings using '==' instead of '.equals()'?
- It compares references instead of values
- It will always cause a syntax eror
- It ignores case sensitivity
- It trims whitespace automatically
- It throws a compile-time excepion
Fixing Floating Point Bug
A student adds 0.1 ten times and expects to get 1.0 but gets 0.999999 instead. What's the error type?
- Floating point precision error
- Logicla loop bug
- Off-by-tne mistake
- Type convertion error
- Null value bug
Incorrect Function Return
A Python function is meant to return True if a list is empty. The code is: if list: return True else: return False. What's the logical error?
- The return values are reversed
- list is misspelled
- No coln after 'else'
- Function never exits
- Syntax is invalid
Debugging Variable Scope
Listen: A variable declared inside a function cannot be accessed outside the function. What kind of error would using this variable outside cause?
- Undefined variable error
- Array index out of bond
- Null point error
- Stack adapt overflod
- Syntax misspell
Zero Division Dilemma
What error occurs in most programming languages when you attempt to divide an integer by zero?
- Division by zero error
- Buffer overrun
- Syntax mistak
- Type of bound
- Off-by-two