Courseiva
mediumMultiple Choice

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 loop body eliminates the work the loop performs, so the program still never terminates while also losing its intended functionality. It is tempting as a quick way to stop repeated execution, but the correct fix alters the loop's termination condition or counter so the exit test eventually evaluates true.

  • ✗

    Add a break statement

    Why it's wrong here

    A break statement exits the loop after the first iteration, so the loop no longer processes the full data set it was written to traverse. It is tempting because it halts the hang immediately, but the correct fix corrects the loop's terminating condition or increment so normal iteration completes.

  • ✓

    Add a counter variable that increments and check it in the condition

    Why this is correct

    An infinite loop occurs because the terminating condition never becomes false. Introducing a counter that increments each iteration and is evaluated in the loop condition gives the loop a reachable exit point, so execution terminates instead of repeating indefinitely.

  • ✗

    Change from a for loop to a while loop

    Why it's wrong here

    Swapping a for loop for a while loop changes only syntax; if the same non-terminating condition is carried over, execution still never exits. It is tempting because while loops appear to offer explicit control, but the fix must modify the condition or counter that governs termination, not the loop construct.

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 →

How Courseiva writes practice questions · Editorial policy

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.