Identifying and Correcting Errors MCQ Practice

Question 1 of 10

Which example is a syntax error in CSP-style pseudocode?

  1. A. Forgetting to test the boundary 0
  2. B. Using the wrong formula but valid statements, yielding an incorrect DISPLAY
  3. C. Writing REPEAT 5 TIME instead of REPEAT 5 TIMES so the environment rejects the line
  4. D. Running out of list range at runtime

Question 2 of 10

Intended: remove the first element of line. Code:

line ← ["Ann", "Bea", "Cal"]
REMOVE(line, 2)
DISPLAY(line)

What is displayed, and what mistake occurred?

  1. A. [Bea, Cal]; correctly removed Ann
  2. B. Syntax error; REMOVE is not allowed
  3. C. [Ann, Bea, Cal]; no removal happened
  4. D. [Ann, Cal]; removed index 2 (Bea) instead of index 1 (Ann)—logic/wrong index

Question 3 of 10

A binary search helper assumes a sorted list but testers pass an unsorted list of seat numbers. The search “fails” to find values that are present.

Best characterization?

  1. A. Logic/precondition violation: algorithm requirements were not met by the input data
  2. B. Overflow because seat numbers are small
  3. C. The values are not present if unsorted
  4. D. Pure syntax error in the word binary

Question 4 of 10

Which pair correctly matches a debugging technique to a goal?

  1. A. Only test happy paths → maximize boundary coverage
  2. B. Hand trace → predict successive variable values for a failing input
  3. C. Delete all tests → increase confidence
  4. D. Ignore runtime messages → faster fixes

Question 5 of 10

A program should accept ages 13–18 inclusive for a youth pass. It rejects 18.

Which corrected condition fixes the boundary bug?

  1. A. age < 0
  2. B. age > 13 AND age < 18
  3. C. age ≥ 13 AND age ≤ 18
  4. D. age = 15 only

Question 6 of 10

After inserting temporary DISPLAY(i) statements inside a loop, a student finds i jumps from 1 to 3 because of an extra increment.

What good debugging practice does this illustrate?

  1. A. Syntax highlighting only
  2. B. Avoiding any evidence of variable values
  3. C. Replacing loops with random guesses permanently
  4. D. Using output to inspect internal state while isolating a logic error

Question 7 of 10

Procedure AddSeat should append a name. Code uses INSERT(seats, 1, name) every time.

Call order seats after call
AddSeat("Jo") ["Jo"]
AddSeat("Ky") ["Ky", "Jo"]
AddSeat("Li") ["Li", "Ky", "Jo"]

Relative to appending at the end, what is wrong?

  1. A. Names are inserted at the front, reversing order versus true append
  2. B. INSERT is a syntax error here
  3. C. Lists cannot hold three names
  4. D. Nothing; this is appending

Question 8 of 10

Which situation is most clearly a runtime error rather than a syntax error?

  1. A. A missing closing brace detected when parsing the file
  2. B. Evaluating scores[LENGTH(scores)+1] during execution and crashing
  3. C. A comment that misspells the author's name
  4. D. Choosing a poor variable name that still runs

Question 9 of 10

Why are multiple test cases better than a single successful run when correcting errors?

  1. A. One success proves all future inputs
  2. B. Tests replace the need for correct syntax
  3. C. They can expose different failure modes, including boundaries and empty inputs
  4. D. CSP forbids running a program twice

Question 10 of 10

Code meant to swap first and second elements:

list ← [10, 20, 30]
list[1] ← list[2]
list[2] ← list[1]
DISPLAY(list)

What is displayed, and how should the swap be fixed?

  1. A. [10, 20, 30]; no assignments ran
  2. B. [30, 20, 10]; overflow occurred
  3. C. [20, 10, 30]; already correct
  4. D. [20, 20, 30]; need a temporary variable to hold the original list[1] before overwriting