Debugging and Logical Errors Quiz: Test Your Detective Skills! Quiz

  1. 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++) { /* ... */ }

    1. Off-by-one error
    2. Infinite loop
    3. Type mismatch
    4. Syntax error
    5. Null pointer error
  2. Uninitialized Variable Puzzle

    Which issue can occur if a variable is used before it is assigned a value?

    1. Uninitialized variable error
    2. Array index out of guts
    3. Overflow error
    4. Type casting wrong
    5. Memory leak
  3. 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'?

    1. Assignment is used instead of comparison
    2. x is undeclared
    3. There is a syntax error in 'print'
    4. The loop is infinite
    5. x is always greater than 5
  4. Loop Control Mystery

    In a while loop missing an increment statement, what kind of error would most likely occur?

    1. Infinite loop
    2. Syntax erorr
    3. Segmentation falut
    4. Stackoverflow exception
    5. Missing semicolan
  5. Array Indexing Test

    Given the code: int[] nums = {1,2,3,4}; print(nums[4]); What kind of error will this produce?

    1. Index out of bounds error
    2. Memory overlow
    3. Floating point exception
    4. Syntax mistake
    5. Null referrence
  6. String Comparison Issue

    In Java, what mistake is made if you compare two strings using '==' instead of '.equals()'?

    1. It compares references instead of values
    2. It will always cause a syntax eror
    3. It ignores case sensitivity
    4. It trims whitespace automatically
    5. It throws a compile-time excepion
  7. 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?

    1. Floating point precision error
    2. Logicla loop bug
    3. Off-by-tne mistake
    4. Type convertion error
    5. Null value bug
  8. 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?

    1. The return values are reversed
    2. list is misspelled
    3. No coln after 'else'
    4. Function never exits
    5. Syntax is invalid
  9. 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?

    1. Undefined variable error
    2. Array index out of bond
    3. Null point error
    4. Stack adapt overflod
    5. Syntax misspell
  10. Zero Division Dilemma

    What error occurs in most programming languages when you attempt to divide an integer by zero?

    1. Division by zero error
    2. Buffer overrun
    3. Syntax mistak
    4. Type of bound
    5. Off-by-two