Sample questions
Question 1Easy
White-box testing needs knowledge of:
- Only the published user manual
- The internal code structure
- Only the written requirements
- The marketing plan of the company
Answer: B. The internal code structure
Explanation
White-box techniques derive tests from the code's structure, such as branches and paths.
Step-by-step solution
- Look inside.
- Know the code.
- That is white-box.
Why the other options are wrong
- A. User manuals describe behaviour only.
- C. Requirements alone are black-box input.
- D. Marketing is unrelated.
Question 2Easy
White-box testing is also called:
- Behavioural testing as a rule
- Acceptance testing
- Structural or glass-box testing
- Exploratory testing
Answer: C. Structural or glass-box testing
Explanation
The tester uses knowledge of the code structure.
Step-by-step solution
- White-box testing uses knowledge of the code structure.
- It is also called structural testing or glass-box testing.
- So the other names point to the same technique.
- The answer is option C.
Why the other options are wrong
- A. Behavioural testing is black-box testing, the opposite.
- B. Acceptance testing is about business needs, not code structure.
- D. Exploratory testing is unscripted testing, not structure-based.
Tip: White-box = glass-box = structural. Black-box = behavioural.
Question 3Easy
Which coverage type ensures every line of code runs at least once?
- Decision coverage
- Condition coverage
- Statement coverage
- Path coverage
Answer: C. Statement coverage
Explanation
Statement coverage measures the proportion of executable statements run by tests.
Step-by-step solution
- Count statements executed.
- Divide by total.
- That is statement coverage.
Why the other options are wrong
- A. Decision coverage needs each outcome of branches.
- B. Condition coverage looks at sub-conditions.
- D. Path coverage needs all paths.
Question 4Medium
Cyclomatic complexity of a function with 1 if and 1 while (no other decisions) is:
- 2
- 4
- 3
- 1
Answer: C. 3
Explanation
V(G) = decision points + 1 = 2 + 1 = 3.
Step-by-step solution
- Cyclomatic complexity = number of decision points + 1.
- There is 1 if and 1 while, so 2 decision points.
- 2 + 1 = 3.
- So the answer is option C, 3.
Why the other options are wrong
- A. 2 would count only one decision point too few.
- B. 4 would count one decision point too many.
- D. 1 would mean no decisions at all.
Tip: Cyclomatic complexity = decision points + 1, where each if or loop counts as one.
Question 5Medium
Mutation testing evaluates:
- The execution speed of the code
- Whether the user interface looks right
- How many testers are available in the team
- How well tests detect small deliberate code changes
Answer: D. How well tests detect small deliberate code changes
Explanation
Mutants are small code changes; if the tests fail on a mutant it is 'killed', otherwise the tests are weak.
Step-by-step solution
- Code is altered slightly.
- Tests should fail.
- Surviving mutants show weak tests.
Why the other options are wrong
- A. Performance is another topic.
- B. UI appearance is unrelated.
- C. Staffing is not measured.
Question 6Medium
A function has 3 independent decision points (if statements) and no loops. What is its cyclomatic complexity?
- 3
- 2
- 4
- 8
Answer: C. 4
Explanation
Cyclomatic complexity equals decisions + 1, so 3 + 1 = 4.
Step-by-step solution
- Count decision points.
- Add one.
- Result 4.
Why the other options are wrong
- A. Three is the number of decisions, not decisions + 1.
- B. Two is too low.
- D. Eight is the number of paths, not complexity.
Question 7Medium
A program has 20 statements and tests execute 15. What is the statement coverage?
- 75%
- 15%
- 80%
- 25%
Answer: A. 75%
Explanation
Coverage is 15 / 20 x 100 = 75%.
Step-by-step solution
- Executed = 15.
- Total = 20.
- 15/20 = 75%.
Why the other options are wrong
- B. 15 is the count, not a percentage.
- C. 80% would be 16 of 20.
- D. 25% is the uncovered share.
Question 8Medium
Code: if (a > 0 && b > 0) { ... }. What is the minimum number of tests for 100% decision coverage?
- 1
- 2
- 4
- 3
Answer: B. 2
Explanation
Decision coverage needs the decision to be both true and false: a=1,b=1 and a=0,b=0 are enough.
Step-by-step solution
- Need one true outcome.
- Need one false outcome.
- Two tests.
Why the other options are wrong
- A. One test cannot make both outcomes happen.
- C. Four are needed for all condition combinations, not decision outcomes.
- D. Three is for MC/DC.
Question 9Hard
Which statement about coverage is correct?
- 100% statement coverage implies 100% decision coverage
- 100% coverage of any type means no defects remain
- 100% decision coverage implies 100% statement coverage
- Statement coverage is a stronger criterion than decision coverage
Answer: C. 100% decision coverage implies 100% statement coverage
Explanation
Decision coverage subsumes statement coverage: executing every branch outcome runs every statement. The reverse does not hold.
Step-by-step solution
- Branches reach statements.
- So decision subsumes statement.
- Reverse is false.
Why the other options are wrong
- A. A single if without else can be statement-covered yet leave the false outcome untested.
- B. Coverage shows what ran, not correctness.
- D. Decision coverage is the stronger one.
Question 10Hard
A function has one if followed by another independent if. What is the minimum number of tests for 100% branch coverage?
- 1
- 2
- 3
- 4
Answer: B. 2
Explanation
One test takes both true, another takes both false; four paths are not required.
Step-by-step solution
- Each if has a true and a false outcome, so there are four outcomes to cover.
- Test 1 with both conditions true covers both true outcomes.
- Test 2 with both conditions false covers both false outcomes.
- So two tests give 100% branch coverage, which is option B.
Why the other options are wrong
- A. One test cannot cover both true and false outcomes of both ifs.
- C. Three tests are more than needed for 100% branch coverage here.
- D. Four tests are more than needed; four paths are not required.
Tip: With independent ifs, pair the outcomes: one test all-true and one test all-false.
Practise all 14 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →