CompTIA PenTest+ (PT0-002) — Question 248
In Java C/C++, variable initialization is critical because:
Answer options
- A. the unknown value, when used later, will cause unexpected behavior.
- B. the compiler will assign null to the variable, which will cause warnings and errors.
- C. the initial state of the variable creates a race condition.
- D. the variable will not have an object type assigned to it.
Correct answer: A
Explanation
The correct answer is A because using an uninitialized variable can lead to unpredictable behavior in the program. Option B is incorrect as compilers do not assign null by default in all cases, and options C and D are irrelevant to the concept of variable initialization in this context.