Software Engineering · Software Engineering and Web Technology
56 questions · asked in 11 of 27 years (2000–2026)
MCQ 53 · NAT 31-mark 42 · 2-mark 14
2000Questions per year2026
Questions 11–15 of 56
In the context of modular software design, which one of the following combinations is desirable?
Answer: (B)
Cohesion measures how closely the parts inside one module belong together. Coupling measures how much modules depend on each other.
A good modular design has high cohesion (each module does one clear job) and low coupling (modules can be changed, tested and reused on their own).
Answer: (B)
A good modular design has high cohesion (each module does one clear job) and low coupling (modules can be changed, tested and reused on their own).
Answer: (B)
The procedure given below is required to find and replace certain characters inside an input character string supplied in array A. The characters to be replaced are supplied in array oldc, while their respective replacement characters are supplied in array newc. Array A has a fixed length of five characters, while arrays oldc and newc contain three characters each. However, the procedure is flawed
(1) oldc = "abc", newc = "dab"
(2) oldc = "cde", newc = "bcd"
(3) oldc = "bca", newc = "cda"
(4) oldc = "abc", newc = "bac"
If array A is made to hold the string "abcde", which of the above four test cases will be successful in exposing the flaw in this procedure?
void find_and_replace (char *A, char *oldc, char *newc) {
for (int i=0; i<5; i++)
for (int j=0; j<3; j++)
if (A[i] == oldc[j]) A[i] = newc[j];
}
The procedure is tested with the following four test cases. (1) oldc = "abc", newc = "dab"
(2) oldc = "cde", newc = "bcd"
(3) oldc = "bca", newc = "cda"
(4) oldc = "abc", newc = "bac"
If array A is made to hold the string "abcde", which of the above four test cases will be successful in exposing the flaw in this procedure?
Answer: (C)
The code checks each against in order, and replaces it as soon as it matches. The flaw: after a replacement, the new character is compared against the later entries of and may be replaced again (a chained replacement). This needs to equal some with .
Test on "abcde":
- Case 1 (abc to dab): is not in oldc, and are earlier entries, which are already passed. No chain, so the output is the correct "dabde". Flaw not exposed.
- Case 2 (cde to bcd): , , never match a later entry of "cde" ( is , earlier than index 1; is , earlier than index 2). Output is the correct "abbcd". Not exposed.
- Case 3 (bca to cda): becomes () and then becomes (). Output has in place 2 instead of . Exposed.
- Case 4 (abc to bac): becomes () and then becomes (). Output keeps instead of . Exposed.
Cases 3 and 4 only.
Answer: (C)
Test on "abcde":
- Case 1 (abc to dab): is not in oldc, and are earlier entries, which are already passed. No chain, so the output is the correct "dabde". Flaw not exposed.
- Case 2 (cde to bcd): , , never match a later entry of "cde" ( is , earlier than index 1; is , earlier than index 2). Output is the correct "abbcd". Not exposed.
- Case 3 (bca to cda): becomes () and then becomes (). Output has in place 2 instead of . Exposed.
- Case 4 (abc to bac): becomes () and then becomes (). Output keeps instead of . Exposed.
Cases 3 and 4 only.
Answer: (C)
The procedure given below is required to find and replace certain characters inside an input character string supplied in array A. The characters to be replaced are supplied in array oldc, while their respective replacement characters are supplied in array newc. Array A has a fixed length of five characters, while arrays oldc and newc contain three characters each. However, the procedure is flawed
(1) oldc = "abc", newc = "dab"
(2) oldc = "cde", newc = "bcd"
(3) oldc = "bca", newc = "cda"
(4) oldc = "abc", newc = "bac"
The tester now tests the program on all input strings of length five consisting of characters 'a', 'b', 'c', 'd' and 'e' with duplicates allowed. If the tester carries out this testing with the four test cases given above, how many test cases will be able to capture the flaw?
void find_and_replace (char *A, char *oldc, char *newc) {
for (int i=0; i<5; i++)
for (int j=0; j<3; j++)
if (A[i] == oldc[j]) A[i] = newc[j];
}
The procedure is tested with the following four test cases. (1) oldc = "abc", newc = "dab"
(2) oldc = "cde", newc = "bcd"
(3) oldc = "bca", newc = "cda"
(4) oldc = "abc", newc = "bac"
The tester now tests the program on all input strings of length five consisting of characters 'a', 'b', 'c', 'd' and 'e' with duplicates allowed. If the tester carries out this testing with the four test cases given above, how many test cases will be able to capture the flaw?
Answer: (B)
The flaw: a character that is already replaced can be replaced a second time later in the j loop. This happens when newc[j] is equal to a later oldc[k] (where k j).
- (1) abc dab: b a, but a comes earlier in oldc so there is no chain
- (2) cde bcd: there is no chain
- (3) bca cda: b c, then c d the flaw is shown
- (4) abc bac: a b, then b a the flaw is shown
Answer: Only two
- (1) abc dab: b a, but a comes earlier in oldc so there is no chain
- (2) cde bcd: there is no chain
- (3) bca cda: b c, then c d the flaw is shown
- (4) abc bac: a b, then b a the flaw is shown
Answer: Only two
The following figure represents access graphs of two modules M1 and M2. The filled circles represent methods and the unfilled circles represent attributes. If method m is moved to module M2 keeping the attributes where they are, what can we say about the average cohesion and coupling between modules in the system of two modules?
Answer: (A)
Count the links of method in the figure. has 2 links to attributes in M1 and 2 links to attributes in M2.
Before the move, the 2 links to M1 attributes are inside the module (they add to cohesion) and the 2 links to M2 attributes cross the module boundary (they add to coupling).
After moves to M2, the 2 links to M2 attributes become internal and the 2 links to M1 attributes become cross-module. So the number of internal links stays the same in total (M1 loses 2, M2 gains 2) and the number of cross-module links stays 2. Neither cohesion nor coupling changes.
Answer: (A)
Before the move, the 2 links to M1 attributes are inside the module (they add to cohesion) and the 2 links to M2 attributes cross the module boundary (they add to coupling).
After moves to M2, the 2 links to M2 attributes become internal and the 2 links to M1 attributes become cross-module. So the number of internal links stays the same in total (M1 loses 2, M2 gains 2) and the number of cross-module links stays 2. Neither cohesion nor coupling changes.
Answer: (A)
The following is comment written for a C function /* This function computes the roots of a quadratic equation a.x^2+b.x+c=0. The function stores two real roots in *root1 and *root2 and returns the status of validity of roots. It handles four different kinds of cases.
i When coefficient a is zero irrespective of discriminant
ii When discriminant is positive
iii When discrimanant is zero
iv When discrimanant is negative
Only in cases ii and iii , the stored roots are valid.
Otherwise 0 is stored in the roots.
The function returns 0 when the roots are valid and -1 otherwise.
The functin also ensures root1>=root2.
int get_QuadRoots float a, ( float b, float c, float *root1, float *root2);
* /
A software test engineer is assigned the job of doing black box testing. He comes up with the following test cases, many of which are redundant.
Which one of the following options provide the set of non-redundant tests using equivalence class partitioning approach from input perspective for black box testing?
i When coefficient a is zero irrespective of discriminant
ii When discriminant is positive
iii When discrimanant is zero
iv When discrimanant is negative
Only in cases ii and iii , the stored roots are valid.
Otherwise 0 is stored in the roots.
The function returns 0 when the roots are valid and -1 otherwise.
The functin also ensures root1>=root2.
int get_QuadRoots float a, ( float b, float c, float *root1, float *root2);
* /
A software test engineer is assigned the job of doing black box testing. He comes up with the following test cases, many of which are redundant.
Which one of the following options provide the set of non-redundant tests using equivalence class partitioning approach from input perspective for black box testing?
Answer: (C)
In equivalence class partitioning, inputs that make the program behave in the same way form one class, and one test per class is enough. Here the classes are decided by and the discriminant .
- T1:
- T2:
- T3:
- T4:
- T5:
- T6:
So the classes are: (T1, T2), (T5), (T3, T4), and (T6). We need one test from each class: one of T1/T2, one of T3/T4, T5 and T6.
Option (C) T2, T4, T5, T6 has exactly one from each class. Option (A) T1, T2, T3, T6 repeats and misses . Option (B) T1, T3, T4, T5 repeats and misses . Option (D) T2, T3, T4, T5 repeats and misses .
Answer: (C)
- T1:
- T2:
- T3:
- T4:
- T5:
- T6:
So the classes are: (T1, T2), (T5), (T3, T4), and (T6). We need one test from each class: one of T1/T2, one of T3/T4, T5 and T6.
Option (C) T2, T4, T5, T6 has exactly one from each class. Option (A) T1, T2, T3, T6 repeats and misses . Option (B) T1, T3, T4, T5 repeats and misses . Option (D) T2, T3, T4, T5 repeats and misses .
Answer: (C)
Keep practising
Topics in Software Engineering and Web Technology
Software EngineeringYou are here
Web Technology