Debugging Detective Quiz Quiz

  1. Syntax Error Identification

    What is the error in the following Python code: `print 'Hello, world'`?

    1. Missing semicolon
    2. Incorrect indentation
    3. SyntaxError: Missing parentheses in call to 'print'
    4. Undeclared variable
    5. Typo in the print statement
  2. Logic Error in Loop

    The following JavaScript code is intended to calculate the sum of numbers from 1 to 5, but it's not working. What's the most likely reason: `let sum = 0; for (let i = 0; i u003C= 5; i++); { sum += i; } console.log(sum);`?

    1. The loop is missing a closing curly brace.
    2. The `let` keyword is not supported.
    3. The semicolon after the `for` loop condition is causing an empty loop.
    4. The `console.log` statement is placed incorrectly.
    5. The loop counter 'i' is never incremented.
  3. Off-by-One Error

    An array in Java has 10 elements. A loop attempts to access each element using its index. What type of error will occur if the loop iterates from 1 to 10 inclusive?

    1. NullPointerException
    2. IndexOutOfBoundsException
    3. ArrayIndexMissingException
    4. AritmeticException
    5. IllegalArugumentException
  4. Incorrect Variable Scope

    In the following C# code, why does `Console.WriteLine(message);` throw an error: `void MyFunction() { string message = 'Hello!'; } Console.WriteLine(message);`?

    1. The variable `message` is not initialized.
    2. The `Console.WriteLine` statement is in the wrong namespace.
    3. The variable `message` is declared as `const`.
    4. The variable `message` is out of scope in the `Console.WriteLine` statement.
    5. The variable `message` is defined as an Integer when it should be a String.
  5. Type Conversion Error

    What error will occur in Python when the code `result = '5' + 3` is executed?

    1. NameError
    2. TypeError: can only concatenate str (not 'int') to str
    3. ValueError
    4. SyntaxError
    5. IndexError
  6. Null Pointer Exception

    What common runtime error occurs when you try to access a member of a variable that has a null or nil value?

    1. Memory Leak
    2. Stack Overflow
    3. NullPointerException
    4. Segmentation Fault
    5. Type Mismatch
  7. Infinite Loop Condition

    Which of the following will likely cause an infinite loop in JavaScript?

    1. for (let i = 0; i u003C 10; i++) {}
    2. while (true) {}
    3. if (true) {}
    4. do {} while (false);
    5. switch (x) {}
  8. Memory Leak Scenario

    In C++, what programming practice is most likely to cause a memory leak if not handled properly?

    1. Using global variables extensively
    2. Dynamic memory allocation with 'new' without corresponding 'delete'
    3. Using recursion excessively
    4. Performing a lot of string concatenations
    5. Opening and closing files frequently
  9. Race Condition Debugging

    Which concurrency issue arises when multiple threads access and modify shared data simultaneously, leading to unpredictable results?

    1. Deadlock
    2. Starvation
    3. Race Condition
    4. Priority Inversion
    5. Thread Collision
  10. Incorrect Boolean Logic

    A program should only execute a certain block of code if 'x' is greater than 5 AND 'y' is less than 10. The condition is written as `if (x u003E 5 || y u003C 10)`. What type of error is this?

    1. Syntax Error
    2. Runtime Error
    3. Logic Error
    4. Type Error
    5. Overflow Error