CS FundamentalsHardProduct-company placement

The condition `x > 5 and x >= 0` (x an integer) is mutated four ways. Which mutant is equivalent, so that no test can kill it?

  1. A. `x > 5 or x >= 0`
  2. B. `x >= 5 and x >= 0`
  3. C. `x > 5 and x <= 0`
  4. D. `x > 5 and x > 0`

Correct answer: D. `x > 5 and x > 0`

Whenever x > 5 holds, both x >= 0 and x > 0 hold, so changing the second test never alters the result. x = 5 kills the >= 5 mutant, x = 0 kills the 'or' mutant, and x = 6 kills the <= 0 mutant.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic