CS FundamentalsHardProduct-company placement · ISTQB-style

In Java, the non-short-circuit operator | evaluates both sides. For `if ((a > 0) | (b > 0)) { X(); } else { Y(); }` the tests (a = 1, b = -1) and (a = -1, b = 1) are run. What do they achieve?

  1. A. 100% condition coverage but only 50% decision coverage
  2. B. 100% condition coverage and 100% decision coverage
  3. C. 50% condition coverage and 100% decision coverage
  4. D. 100% multiple-condition coverage

Correct answer: A. 100% condition coverage but only 50% decision coverage

Each condition takes both True and False, but the decision is True in both tests, so Y() never runs: decision coverage is 50%. This is the classic case showing condition coverage does not subsume decision coverage; multiple-condition coverage would need all 4 combinations.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic