ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 33 - CTAL-TTA discussion

Report
Export

You have been assigned to perform a review on code provided below:

Which type of defect should you report as part of the code review?

A.
Endless loop
Answers
A.
Endless loop
B.
Unreachable code
Answers
B.
Unreachable code
C.
Too many nested levels
Answers
C.
Too many nested levels
D.
No defects should be reported, code is correct.
Answers
D.
No defects should be reported, code is correct.
Suggested answer: A

Explanation:

The code provided contains a potential endless loop. The loop is conditioned on the variable 'E' being less than 1 (IF E < 1), but within the loop, there is no operation that modifies the value of 'E'. Therefore, once the loop is entered, if the condition A > B holds true, the value of 'E' remains unchanged, leading to an endless loop situation. The decrement of 'A' in line 15 does not guarantee an exit condition for the loop, as it does not affect the value of 'E'. This is a control flow defect that could cause the program to hang or crash.

asked 18/09/2024
Edmond Chui
35 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first