Consider the following method:
int f(int m, int n, boolean x, boolean y)
{
int res = 0;
if (m < 0) { res = n − m; }
else if (x || y) {
res = −1;
if (n == m) { res = 1; }
}
else { res = n; }
return res;
} /* end of f */If P is the minimum number of tests for full statement coverage of f() and Q is the minimum number for full branch coverage, then (P, Q) =
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: A. (3,4)
Explanation
Statements: one test with m < 0, one with x || y true and n == m (covers res = −1 and res = 1), one with everything false: P = 3. Branches also need the n == m false outcome, adding a fourth test: Q = 4.
More Software Engineering questions
- For a software system P: estimated size 33,480 LOC; average productivity 620 LOC per person-month; 6 developers; average salary ₹50,000 per…
- Match the following in Software Engineering :
- A software system crashed 20 times in the year 2017 and for each crash, it took 2 minutes to restart. Approximately, what was the software…
- Match the 5 CMM Maturity levels/CMMI staged representations in List- I with their characterizations in List-II
- Which of the following statements is/are false? P: The clean-room strategy for software engineering is based on the incremental software pr…
- Software validation mainly checks for inconsistencies between