White-box Techniques Questions with Answers

14 practice questions on White-box Techniques (Software Testing & QA) with answers and step-by-step solutions. Try 10 samples below, then practise all 14 free in the AptiNest app.

Sample questions

Question 1Easy

White-box testing needs knowledge of:

  1. Only the published user manual
  2. The internal code structure
  3. Only the written requirements
  4. 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

  1. Look inside.
  2. Know the code.
  3. 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:

  1. Behavioural testing as a rule
  2. Acceptance testing
  3. Structural or glass-box testing
  4. Exploratory testing

Answer: C. Structural or glass-box testing

Explanation

The tester uses knowledge of the code structure.

Step-by-step solution

  1. White-box testing uses knowledge of the code structure.
  2. It is also called structural testing or glass-box testing.
  3. So the other names point to the same technique.
  4. 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?

  1. Decision coverage
  2. Condition coverage
  3. Statement coverage
  4. Path coverage

Answer: C. Statement coverage

Explanation

Statement coverage measures the proportion of executable statements run by tests.

Step-by-step solution

  1. Count statements executed.
  2. Divide by total.
  3. 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:

  1. 2
  2. 4
  3. 3
  4. 1

Answer: C. 3

Explanation

V(G) = decision points + 1 = 2 + 1 = 3.

Step-by-step solution

  1. Cyclomatic complexity = number of decision points + 1.
  2. There is 1 if and 1 while, so 2 decision points.
  3. 2 + 1 = 3.
  4. 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:

  1. The execution speed of the code
  2. Whether the user interface looks right
  3. How many testers are available in the team
  4. 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

  1. Code is altered slightly.
  2. Tests should fail.
  3. 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?

  1. 3
  2. 2
  3. 4
  4. 8

Answer: C. 4

Explanation

Cyclomatic complexity equals decisions + 1, so 3 + 1 = 4.

Step-by-step solution

  1. Count decision points.
  2. Add one.
  3. 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?

  1. 75%
  2. 15%
  3. 80%
  4. 25%

Answer: A. 75%

Explanation

Coverage is 15 / 20 x 100 = 75%.

Step-by-step solution

  1. Executed = 15.
  2. Total = 20.
  3. 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. 1
  2. 2
  3. 4
  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

  1. Need one true outcome.
  2. Need one false outcome.
  3. 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?

  1. 100% statement coverage implies 100% decision coverage
  2. 100% coverage of any type means no defects remain
  3. 100% decision coverage implies 100% statement coverage
  4. 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

  1. Branches reach statements.
  2. So decision subsumes statement.
  3. 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. 1
  2. 2
  3. 3
  4. 4

Answer: B. 2

Explanation

One test takes both true, another takes both false; four paths are not required.

Step-by-step solution

  1. Each if has a true and a false outcome, so there are four outcomes to cover.
  2. Test 1 with both conditions true covers both true outcomes.
  3. Test 2 with both conditions false covers both false outcomes.
  4. 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 →

Related topics

See all Software Testing & QA topics · All topics