This set of JUnit Multiple Choice Questions & Answers (MCQs) focuses on ” JMock”.
1. The Cobertura command for merging datafiles is ________________
a) cobertura-report.bat
b) cobertura-instrument.bat
c) cobertura-check.bat
d) cobertura-merge.bat
View Answer
Explanation: The cobertura-merge.bat command is used along with parameters to run merging using Cobertura.
2. In order to write testable code, ______________ should be reduced as much as possible.
a) Dependencies
b) Redundancies
c) Objects
d) Classes
View Answer
Explanation: Classes with too many dependencies require complicated tests.
3. A solution to reducing dependencies is to separate code between methods that instantiate new ____________ and methods that provide application logic.
a) Classes
b) Objects
c) Modules
d) Functions
View Answer
Explanation: Separation of objects and logic leads to reduced dependencies.
4. ________________ is a design guideline that states that one class should know only as much as it needs to know.
a) Law of knowledge
b) Class laws
c) Law of Demeter
d) Action methods
View Answer
Explanation: The law of demeter is also known as the Principle of Least Knowledge.
5. ____________ is a useful design pattern that ensures a class has only one instance.
a) Modular code
b) Lossless paradigm
c) Granular methods
d) Singleton
View Answer
Explanation: Most often, the implementation of a singleton defines a private constructor and a static variable.
6. The obvious drawback of a singleton is that it introduces _____________ into the application.
a) Redundancies
b) Errors
c) Global State
d) Modules
View Answer
Explanation: The global state object can be accessed by anyone.
7. _______________ can easily be used to substitute application code with the test code.
a) Encapsulation
b) Polymorphism
c) Overloading
d) Static binding
View Answer
Explanation: Polymorphism is used to force certain code patterns to be tested.
8. At runtime, code can’t change a/an ___________ hierarchy.
a) Encapsulation
b) Polymorphism
c) Overloading
d) Inheritence
View Answer
Explanation: As code cannot change the hierarchy, objects needs to be composed differently.
9. For wrtiting favourable tests, __________ is perferred over inheritance.
a) Encapsulation
b) Polymorphism
c) Overloading
d) Composition
View Answer
Explanation: Composition is a better code re-use mechanism.
10. One of the main ways to decrease complexity is to try to avoid long _________ and if statements.
a) switch
b) then
c) default
d) static
View Answer
Explanation: Long switch statements increase the complexity of code and corresponding test cases.
Sanfoundry Global Education & Learning Series – JUnit.
To practice all areas of Junit, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Check JUnit Books
- Check Programming Books
- Apply for Computer Science Internship
- Practice Programming MCQs