White-Box Testing MCQs: 11 Solved Basis Path and Control Structure Questions

Solve 11 published white-box testing questions, then use a compact control-flow example to check coverage, loop boundaries, and independent paths.

KnowledgeGate Team

Exam prep & CS education

Updated 3 Dec 20267 min read
White-Box Testing MCQs: 11 Solved Basis Path and Control Structure Questions

White-box testing derives cases from internal code structure. Statement coverage counts executed statements, branch coverage counts decision outcomes, and basis path testing selects independent control-flow routes. For each question, write one line of working before checking the answer; numeric items need the path or denominator, while definition items need the controlling concept.

A control-flow and basis-path refresher before the MCQs

Control-flow graph with three basis paths and a loop-boundary test for zero, one, and multiple iterations.

Statement coverage is executed statements divided by total statements. Branch coverage is executed decision outcomes divided by total decision outcomes. A basis set contains linearly independent control-flow paths, with each path adding at least one edge not covered by earlier paths. It is not every possible path, since loops can make that set unbounded.

Code
N1: read x, y
N2: if x > 0
N3:     y = y + 1
    else
N4:     y = y - 1
N5: while y < 3
N6:     y = y + 1
N7: print y

The eight edges are N1->N2, N2(T)->N3, N2(F)->N4, N3->N5, N4->N5, N5(T)->N6, N6->N5 and N5(F)->N7. Therefore V(G) = E - N + 2 = 8 - 7 + 2 = 3. The cross-check is two decisions plus one, again 3.

  • A: x = 1, y = 2 follows N1-N2(T)-N3-N5(F)-N7 and prints 3.

  • B: x = -1, y = 4 follows N1-N2(F)-N4-N5(F)-N7 and prints 3.

  • C: x = -1, y = 2 follows N1-N2(F)-N4-N5(T)-N6-N5(T)-N6-N5(F)-N7, iterates twice and prints 3.

These form three independent paths. The boundary test x = -1, y = 3 reaches y = 2 after N4, runs the loop once and prints 3. Together, the four tests distinguish zero, one and more-than-one iterations. The three-path basis and the loop-boundary set answer related, but different, questions.

White-box MCQs 1-2: calculate statement and branch coverage

Question 1 (GATE 2010)

The following program is to be tested for statement coverage:

Code
begin

    if (a==b) {S1; exit;}

    else if (c==d) {S2;}

        else {S3; exit;}

    S4;

end

The test cases T1, T2, T3 and T4 given below are expressed in terms of the properties satisfied by the values of variables a, b, c and d. The exact values are not given.

T1: a, b, c and d are all equal

T2: a, b, c and d are all distinct

T3: a = b and c != d

T4: a != b and c = d

Which of the test suites given below ensures coverage of statements S1, S2, S3 and S4?

  • A. T1, T2, T3

  • B. T2, T4

  • C. T3, T4

  • D. T1, T2, T4

Answer: D. T1, T2, T4.

T1 executes S1 and exits. T2 makes both comparisons false, executes S3 and exits. T4 executes S2 and then S4, so D covers all four statements; T3 only repeats T1's S1 coverage.

Question 2 (GATE 2007, Information Technology)

In the simplified flowchart given below, the shaded boxes represent code that is executed during a test case.

Control-flow graph with shaded nodes tracing one executed route through three of eight branch outcomes.

The Branch coverage is

  • A. 3/4

  • B. 2/3

  • C. 1/2

  • D. 3/8

Answer: D. 3/8.

Count outcomes, not shaded boxes. Four binary decisions give 4 x 2 = 8 branch outcomes, and the route takes three, so coverage is 3/8. The denominator in 3/4 counts decisions rather than their outcomes.

White-box MCQs 3-4: loops, statement coverage and operational bounds

Question 3 (GATE 2008, Information Technology)

Find if the following statements in the context of software testing are TRUE or FALSE.

(S1) Statement coverage cannot guarantee execution of loops in a program under test.

(S2) Use of independent path testing criterion guarantees execution of each loop in a program under test more than once.

  • A. True, True

  • B. True, False

  • C. False, True

  • D. False, False

Answer: A. True, True.

Statement coverage may touch a loop body without testing repetition, so S1 is true. In the independent-path sense used here, loop-created paths must be exercised rather than touched once, so S2 is treated as true. Basis path testing still does not enumerate every iteration count.

Question 4 (ISRO 2007 and BEL 2007)

To execute all loops at their boundaries and within their operational bounds is an example of

  • A. Black Box Testing

  • B. Alpha Testing

  • C. Recovery Testing

  • D. White Box Testing

Answer: D. White Box Testing.

Zero, one and multiple loop iterations come from the program's control structure, so this is white-box testing. Black-box testing starts from visible requirements; alpha and recovery testing have different objectives.

White-box MCQs 5-7: structural testing, glass-box testing and internal code

Question 5

White Box techniques can also be classified as

  • A. Design based testing

  • B. Structural testing

  • C. Error guessing technique

  • D. None of the mentioned

Answer: B. Structural testing.

White-box techniques examine implementation structures such as statements, decisions, paths and data flow. Error guessing is experience-based, while “design based testing” is not the matching classification in this item.

Question 6 (DSSSB 2021, TGT - Shift 1)

What is the other name of White-box testing?

  • A. Red-box testing

  • B. Glass-box testing

  • C. Open-box testing

  • D. Close-box testing

Answer: B. Glass-box testing.

"Glass-box" means the tester can see and use the internal logic while selecting tests. Among these options, only B is the established synonym.

Question 7 (TPSC 2026, Programmer)

What is the main objective of white-box testing ?

  • A. Test without knowledge of internal structure

  • B. Test based on internal code structure

  • C. Test user interface only

  • D. Test system integration

Answer: B. Test based on internal code structure.

White-box tests are derived from code structure and logic. Option A describes the black-box viewpoint, while interface and integration checks are scopes that do not by themselves establish white-box testing.

White-box MCQs 8-9: basis paths and the objective of structural testing

Question 8 (UGC NET 2012, December)

Basis path testing falls under

  • A. system testing

  • B. white box testing

  • C. black box testing

  • D. unit testing

Answer: B. white box testing.

Basis path testing builds a control-flow graph and selects independent paths, so it requires implementation knowledge. Unit and system are testing levels; white box and black box describe test derivation.

Question 9 (MPPSC 2025)

The objective of structural testing is to ensure that each independent program path is executed __________

  • A. at least twice

  • B. at least half

  • C. at least once

  • D. at most twice

Answer: C. at least once.

A basis set contains independent paths that add new edges, and each must run at least once. The distractors demand repetition, give no criterion, or impose an irrelevant ceiling.

White-box MCQs 10-11: specifications versus structural coverage

Question 10 (UGC NET 2015, Paper 2, December)

Which one of the following statements is incorrect ?

  • A. Pareto analysis is a statistical method used for analyzing causes, and is one of the primary tools for quality management.

  • B. Reliability of a software specifies the probability of failure-free operation of that software for a given time duration.

  • C. The reliability of a system can also be specified as the Mean Time To Failure (MTTF).

  • D. In white-box testing, the test cases are decided from the specifications or the requirements.

Answer: D. In white-box testing, the test cases are decided from the specifications or the requirements.

Requirements-driven selection uses the external contract, the black-box viewpoint. White-box cases come from statements, branches, conditions and paths, so D is incorrect. A to C cover cause prioritisation, failure-free operation over time, and MTTF as a reliability measure.

Question 11 (UGC NET 2018, Paper 2, December)

Consider the following method:

Code
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;
}

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) =

  • A. (3, 4)

  • B. (4, 3)

  • C. (2, 3)

  • D. (3, 2)

Answer: A. (3, 4).

Three statement-coverage tests are necessary: one for m < 0, one for x || y with n == m, and one for x || y false. Branch coverage needs a fourth test because the nested n == m decision needs both true and false outcomes while x || y remains true. Inputs (-1, 5, false, false), (2, 2, true, false), (2, 3, true, false), and (2, 3, false, false) exercise the required outcomes, so (P, Q) = (3, 4). Review the item in the UGC NET question page.

Score the set and choose the next practice step

Use misses as a diagnostic map, not as a predicted score.

Questions missed

What to revise

1-2

Redraw executed statements and count decision outcomes.

3-4

Test loops at zero, one and multiple iterations.

5-7

Tie white box to program structure and internal visibility.

8-11

Separate basis paths and code structure from requirements-driven tests, then recompute coverage counts.

Retest Questions 1, 2, 3, 8, 9 and 11 without looking. Recompute E = 8, N = 7 and V(G) = 3, then trace zero, one and two loop iterations. Cyclomatic Complexity MCQs: 12 Independent-Path Questions Solved concentrates on E - N + 2, predicate counts, regions and basis-set arithmetic; statement and branch coverage, loop boundaries and white-box classification remain the practice targets here. For wider context, read Software Quality in Software Engineering and use the UGC NET CS Exam Preparation category. Continue with NTA-UGC-NET Paper - 2, or take the GATE CS route through GATE Guidance by Sanchit Sir.

The short version: statement coverage asks whether code ran, branch coverage asks which decision outcomes ran, and basis path testing asks which independent routes complete the control-flow set.