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?
- A. 100% condition coverage but only 50% decision coverage
- B. 100% condition coverage and 100% decision coverage
- C. 50% condition coverage and 100% decision coverage
- 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.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- With short-circuit evaluation, how many distinct evaluation patterns (which conditions are evaluated and their values) can the decision (A…
- A loop can execute between 0 and 10 times (n = 10). Following Beizer's guidelines for simple-loop testing, which set of iteration counts…
- A function is a straight sequence of three independent if-else statements, with no loops. What are (total entry-to-exit paths, cyclomatic…
- How many definition-use (def-use) pairs does variable x have in this fragment (a p-use in a condition counts as a use)? python x =…
- For the function below, the tests (age = 30, member = True) and (age = 10, member = False) already give 100% statement and branch…
- McCabe's V(G) = E - N + 2 for one function comes from the cyclomatic number of a strongly connected graph, E - N + P. Where does the '+2'…