Syntax Error Identification
What is the error in the following Python code: `print 'Hello, world'`?
- Missing semicolon
- Incorrect indentation
- SyntaxError: Missing parentheses in call to 'print'
- Undeclared variable
- Typo in the print statement
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);`?
- The loop is missing a closing curly brace.
- The `let` keyword is not supported.
- The semicolon after the `for` loop condition is causing an empty loop.
- The `console.log` statement is placed incorrectly.
- The loop counter 'i' is never incremented.
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?
- NullPointerException
- IndexOutOfBoundsException
- ArrayIndexMissingException
- AritmeticException
- IllegalArugumentException
Incorrect Variable Scope
In the following C# code, why does `Console.WriteLine(message);` throw an error: `void MyFunction() { string message = 'Hello!'; } Console.WriteLine(message);`?
- The variable `message` is not initialized.
- The `Console.WriteLine` statement is in the wrong namespace.
- The variable `message` is declared as `const`.
- The variable `message` is out of scope in the `Console.WriteLine` statement.
- The variable `message` is defined as an Integer when it should be a String.
Type Conversion Error
What error will occur in Python when the code `result = '5' + 3` is executed?
- NameError
- TypeError: can only concatenate str (not 'int') to str
- ValueError
- SyntaxError
- IndexError
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?
- Memory Leak
- Stack Overflow
- NullPointerException
- Segmentation Fault
- Type Mismatch
Infinite Loop Condition
Which of the following will likely cause an infinite loop in JavaScript?
- for (let i = 0; i u003C 10; i++) {}
- while (true) {}
- if (true) {}
- do {} while (false);
- switch (x) {}
Memory Leak Scenario
In C++, what programming practice is most likely to cause a memory leak if not handled properly?
- Using global variables extensively
- Dynamic memory allocation with 'new' without corresponding 'delete'
- Using recursion excessively
- Performing a lot of string concatenations
- Opening and closing files frequently
Race Condition Debugging
Which concurrency issue arises when multiple threads access and modify shared data simultaneously, leading to unpredictable results?
- Deadlock
- Starvation
- Race Condition
- Priority Inversion
- Thread Collision
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?
- Syntax Error
- Runtime Error
- Logic Error
- Type Error
- Overflow Error