mediumMultiple ChoiceObjective-mapped
FC0-U71 Practice Question: A web application is not responding to user input
A web application is not responding to user input. The developer checks the code and finds an infinite loop. Which change will fix the infinite loop?
⚠ Common exam trap
A common mix-up: candidates think changing the loop type (e.g., for to while) or removing the body will fix the infinite loop, but the core issue is the lack of a proper termination condition, which only a counter or similar mechanism can resolve.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Add a counter variable that increments and check it in the condition
An infinite loop occurs when the loop's termination condition is never met. By adding a counter variable that increments with each iteration and checking it in the condition, the loop will eventually exit when the counter reaches a specified limit, thus breaking the infinite loop.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Remove the loop body
Why it's wrong here
Removing the body does not change the loop condition; it will still loop forever.
- ✗
Add a break statement
Why it's wrong here
A break can exit the loop, but if placed incorrectly, it may not be executed.
- ✓
Add a counter variable that increments and check it in the condition
Why this is correct
A counter limits the number of iterations, ensuring the loop eventually ends.
- ✗
Change from a for loop to a while loop
Why it's wrong here
Both loop types can be infinite; changing type does not fix the infinite condition.
Go deeper
Related to this question
About these practice questions
One of 988 original FC0-U71 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This FC0-U71 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the FC0-U71 exam.