JUnit Questions and Answers – Stubbing a Web Server’s Resources

This set of JUnit Online Quiz focuses on “Stubbing a Web Server’s Resources”.

1. ______________ requires that only the first and second conditions of the RIP model are satisfied.
a) Weak mutation testing
b) Strong mutation testing
c) Weak test data
d) Strong test data
View Answer

Answer: a
Explanation: Weak mutation testing is satisfied if only the reach and inspect stages of the RIP model is met.

2. Weak mutation is closely related to ____________ methods.
a) Code Conduct
b) Code Coverage
c) Mutation Coverage
d) Mutation Redundancy
View Answer

Answer: b
Explanation: Weak mutation checks for only two steps, searching for faults similar to those found by Code coverage methods.

3. ________________ is a measure used to describe the degree to which the source code of a program is executed when a particular test suite runs.
a) Code Conduct
b) Code Coverage
c) Mutation Coverage
d) Mutation Redundancy
View Answer

Answer: b
Explanation: Code coverage checks the percentage of the source code that is executed during testing by test data.
advertisement
advertisement

4. _______________ is usually defined as a rule or requirement, which test suite needs to satisfy.
a) Code Conduct
b) Code Coverage
c) Coverage Criteria
d) Mutation Redundancy
View Answer

Answer: c
Explanation: Coverage Criteria defines the rules or criteria which the test suites need to pass.

5. For the statement if( a || b) , which is not a mutant?
a) if(a && b)
b) if(a & b)
c) if( a | b)
d) if( a || b)
View Answer

Answer: d
Explanation: The other three statements alter the original by changing the logical operator, hence introducing mutants.
Note: Join free Sanfoundry classes at Telegram or Youtube

6. Mutants which result in programs which are behaviourally equivalent to the original one are called ________________-
a) Statement coverage
b) Condition coverage
c) Equivalent Mutants
d) Dead Mutants
View Answer

Answer: c
Explanation: An equivalent mutant for the expression a=b+c would be a= b-(-c).

7. For the following function,

advertisement
  1. int example (int x, int y)
  2. {
  3.     int z = 0;
  4.     if ((x>0) && (y>0))
  5.     {
  6.         z = x;
  7.     }
  8.     return z;
  9. }

Which function call ensure statement coverage for this function?
a) example(0,0)
b) example(1,0)
c) example(0,1)
d) example(1,1)
View Answer

Answer: d
Explanation: The function call example(1,1) results in each statement of the function being executed leading to statement coverage.
advertisement

8. For the following function,

  1. int example (int x, int y)
  2. {
  3.     int z = 0;
  4.     if ((x>0) && (y>0))
  5.     {
  6.         z = x;
  7.     }
  8.     return z;
  9. }

Which function call ensure function coverage for this function?
a) ex(1,2)
b) example(3,4)
c) example1(1,2)
d) etra(2,3)
View Answer

Answer: b
Explanation: If during execution function ‘example’ is called at least once, then function coverage for this function is satisfied.
9. For the following function,

  1. int example (int x, int y)
  2. {
  3.     int z = 0;
  4.     if ((x>0) && (y>0))
  5.     {
  6.         z = x;
  7.     }
  8.     return z;
  9. }

Which function call ensure branch coverage for this function?
a) example(1,1)
b) example(0,1)
c) example(1,1) and example(0,1)
d) example(1,1) and example(1,1)
View Answer

Answer: c
Explanation: In the first case, the two if conditions are met and z = x; is executed, while in the second case, the first condition (x>0) is not satisfied, which prevents executing z = x;

10. For the following function,

  1. int example (int x, int y)
  2. {
  3.     int z = 0;
  4.     if ((x>0) && (y>0))
  5.     {
  6.         z = x;
  7.     }
  8.     return z;
  9. }

Which function call ensures condition coverage for this function?
a) example(1,1)
b) example(0,1)
c) example(1,1) and example(0,1)
d) example(1,0) and example(0,1)
View Answer

Answer: d
Explanation: These are necessary because in the first cases, (x>0) evaluates to true whereas in the second, it evaluates false. At the same time, the first case makes (y>0) false, whereas the second makes it true.

Sanfoundry Global Education & Learning Series – JUnit.
To practice all areas of JUnit for Online Quizzes, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.