True or false: A program can pass several tests and still be incorrect.
11 Testing and Debugging Online Quiz Questions
Use this free practice quiz with 20 questions to review 11 Testing and Debugging, test your knowledge, and prepare for your next test or exam.
A program executes the statement average = total / count when count is 0. What type of error is this?
- A
Syntax error
- B
Runtime error
- C
Logic error
- D
Specification error
What is the technical term for a new failure caused by a change intended to fix another problem?
A test compares the with the .
True or false: In Python, assertions should not be the only protection against invalid user input because optimized execution can remove them.
- A
True
- B
False
A method accepts ages from 0 through 120 inclusive. Which test set best applies boundary analysis?
- A
0, 1, 60, 119, 120
- B
-1, 0, 60, 120, 121
- C
-1, 0, 1, 119, 120, 121
- D
1, 2, 60, 118, 119
The function count_even(values) increments its count when value % 2 == 0. What count does it return for [3, 8, 5, 10]?
A failure that can be demonstrated reliably with a small input is called a .
Which actions are appropriate uses of a debugger during systematic investigation? Select all that apply.
- A
Pause execution at a breakpoint
- B
Execute one statement at a time
- C
Inspect variables and expressions
- D
Change several unrelated lines before forming a hypothesis
- E
Ignore the call stack
Which cases should be included when testing a method that searches for a target in an array? Select all that apply.
- A
The target at the first position
- B
The target at the last position
- C
The target in the middle
- D
A target that does not occur
- E
An empty array
- F
An array with duplicate values
- G
Only a typical nonempty array with one match
A function must visit every valid index of values, including the final index. Which loop expression should replace range(len(values) - 1)?
- A
range(len(values) - 1) - B
range(1, len(values)) - C
range(len(values)) - D
range(len(values) + 1)
In the average(values) example, which condition is most appropriate for an internal assertion rather than ordinary validation?
- A
Whether an untrusted user supplied a nonempty list
- B
Whether the computed average lies between the minimum and maximum values
- C
Whether a required file exists before opening it
- D
Whether a user entered an allowed age
A function sometimes produces an incorrect result, but no error message appears. Describe a systematic debugging and testing workflow for finding and fixing the defect. Explain the purpose of the major steps.
A function is intended to classify age 18 as adult, but it uses return age > 18. The program runs without raising an exception, yet it classifies 18 incorrectly. What type of error is this?
- A
Syntax error
- B
Logic error
- C
Runtime error
- D
Traceback error
After reproducing a failure and reading the diagnostic information, which action best follows a systematic debugging process?
- A
Change several nearby lines to see whether the error disappears
- B
Ignore the expected result and inspect only the final error message
- C
State a specific explanation for the suspected defect and test it
- D
Rewrite the entire function before reproducing the problem
A method accepts ages from 0 through 120 inclusive. Which test set most directly checks both valid boundaries and the values immediately outside them?
- A
1, 60, and 119
- B
0, 60, and 120
- C
-1, 1, and 121
- D
-1, 0, 1, 119, 120, and 121
Consider sum_values([4, 7, 2]) implemented with for index in range(len(values) - 1):. What defect would a trace reveal?
- A
The loop omits the final element
- B
The loop processes the first element twice
- C
The loop starts with index 1 instead of index 0
- D
The loop processes one extra element after the list ends
True or false: Passing a finite set of tests generally proves that an arbitrary program is correct for every possible input in its domain.
- A
True
- B
False
What is the testing term for a test added to ensure that a fixed defect does not return after future changes?
What programming term describes a property that should remain true at a defined point in execution, such as after every iteration of a loop?