ITPEC FE Morning April 2022 Question 48

Which of the following is a technique that embeds logical expressions that hold true for the relations or conditions between variables at specific points in the execution of a program and verifies the validity of the program?

Explanation

Assertion check — conditions that must hold at given points are written into the program and verified as it runs.

An assertion such as assert(count >= 0) states the relation between variables expected at that point in the program. When execution reaches it, the condition is evaluated; if it is false, the program reports the violation, pinpointing where the actual state departs from the design. It is used in debugging and to verify that a program is valid.

Answer (a)

Why not others:

  • •(b) Code trace — records the order in which statements execute and how values change, without stating what ought to be true
  • •(c) Snapshot dump — prints the contents of memory or variables at chosen points for inspection, again with no condition to check
  • •(d) Test coverage analysis — measures how much of the code, such as statements or branches, the tests have exercised, not whether conditions hold

Key rule: Traces and dumps show what happened; an assertion states what should be true and flags any difference automatically.

System Development Technology · AI-written, may contain errors

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.