Software Engineering · Question 22 · Medium
What is the minimum number of test cases needed for 100% branch (decision) coverage of this code?
if (a > 0)
x = x + 1;
if (b > 0)
y = y + 1;
- 2
- 1
- 3
- 4
Answer and explanation
Answer: A. 2
Explanation: Each if needs a true outcome and a false outcome. One test with a > 0 and b > 0 covers both true branches, and one test with a <= 0 and b <= 0 covers both false branches. A single test cannot do both.
Previous: In software quality, which question does verification answer, as opposed to… · Next: Which type of coupling between modules is considered the worst (strongest)?
Practise software engineering
Try a fresh set of software engineering questions with an explanation after every answer, free and without signing up: Software Engineering practice. Or sit a full placement mock test.
More software engineering questions
- Which git command adds changes from the working directory to the staging area…
- "The results page must load within 2 seconds for up to 10,000 concurrent…
- In software quality, which question does verification answer, as opposed to…
- Which type of coupling between modules is considered the worst (strongest)?
- You have uncommitted changes but must switch branches quickly to fix an urgent…
- A bad commit has already been pushed to a shared main branch that teammates…
- A Scrum team completed 30, 34 and 26 story points in its last three sprints…
- What is the cyclomatic complexity of this procedure?
- Using Basic COCOMO in organic mode, Effort = 2.4 × (KLOC)^1.05 person-months…
- In mutation testing, 50 mutants are generated. 5 of them are equivalent…
More technical & programming practice
Cloud & DevOps · GenAI Basics · Pseudo-code · C Programming · Java · Python · Data Structures · Algorithms
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge