Free Practice Quiz Question List

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.

20 questions
01
True or false
1 point

True or false: A program can pass several tests and still be incorrect.

  1. A

    True

  2. B

    False

02
Choose one
1 point

A program executes the statement average = total / count when count is 0. What type of error is this?

  1. A

    Syntax error

  2. B

    Runtime error

  3. C

    Logic error

  4. D

    Specification error

03
Written response
1 point

What is the technical term for a new failure caused by a change intended to fix another problem?

04
Fill in the blank
1 point

A test compares the with the .

05
True or false
1 point

True or false: In Python, assertions should not be the only protection against invalid user input because optimized execution can remove them.

  1. A

    True

  2. B

    False

06
Choose one
1 point

A method accepts ages from 0 through 120 inclusive. Which test set best applies boundary analysis?

  1. A

    0, 1, 60, 119, 120

  2. B

    -1, 0, 60, 120, 121

  3. C

    -1, 0, 1, 119, 120, 121

  4. D

    1, 2, 60, 118, 119

07
Written response
1 point

The function count_even(values) increments its count when value % 2 == 0. What count does it return for [3, 8, 5, 10]?

08
Fill in the blank
1 point

A failure that can be demonstrated reliably with a small input is called a .

09
Choose all
1 point

Which actions are appropriate uses of a debugger during systematic investigation? Select all that apply.

  1. A

    Pause execution at a breakpoint

  2. B

    Execute one statement at a time

  3. C

    Inspect variables and expressions

  4. D

    Change several unrelated lines before forming a hypothesis

  5. E

    Ignore the call stack

10
Choose all
1 point

Which cases should be included when testing a method that searches for a target in an array? Select all that apply.

  1. A

    The target at the first position

  2. B

    The target at the last position

  3. C

    The target in the middle

  4. D

    A target that does not occur

  5. E

    An empty array

  6. F

    An array with duplicate values

  7. G

    Only a typical nonempty array with one match

11
Choose one
1 point

A function must visit every valid index of values, including the final index. Which loop expression should replace range(len(values) - 1)?

  1. A

    range(len(values) - 1)

  2. B

    range(1, len(values))

  3. C

    range(len(values))

  4. D

    range(len(values) + 1)

12
Choose one
1 point

In the average(values) example, which condition is most appropriate for an internal assertion rather than ordinary validation?

  1. A

    Whether an untrusted user supplied a nonempty list

  2. B

    Whether the computed average lies between the minimum and maximum values

  3. C

    Whether a required file exists before opening it

  4. D

    Whether a user entered an allowed age

13
Open ended
1 point

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.

14
Choose one
1 point

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?

  1. A

    Syntax error

  2. B

    Logic error

  3. C

    Runtime error

  4. D

    Traceback error

15
Choose one
1 point

After reproducing a failure and reading the diagnostic information, which action best follows a systematic debugging process?

  1. A

    Change several nearby lines to see whether the error disappears

  2. B

    Ignore the expected result and inspect only the final error message

  3. C

    State a specific explanation for the suspected defect and test it

  4. D

    Rewrite the entire function before reproducing the problem

16
Choose one
1 point

A method accepts ages from 0 through 120 inclusive. Which test set most directly checks both valid boundaries and the values immediately outside them?

  1. A

    1, 60, and 119

  2. B

    0, 60, and 120

  3. C

    -1, 1, and 121

  4. D

    -1, 0, 1, 119, 120, and 121

17
Choose one
1 point

Consider sum_values([4, 7, 2]) implemented with for index in range(len(values) - 1):. What defect would a trace reveal?

  1. A

    The loop omits the final element

  2. B

    The loop processes the first element twice

  3. C

    The loop starts with index 1 instead of index 0

  4. D

    The loop processes one extra element after the list ends

18
True or false
1 point

True or false: Passing a finite set of tests generally proves that an arbitrary program is correct for every possible input in its domain.

  1. A

    True

  2. B

    False

19
Written response
1 point

What is the testing term for a test added to ensure that a fixed defect does not return after future changes?

20
Written response
1 point

What programming term describes a property that should remain true at a defined point in execution, such as after every iteration of a loop?