This set of JUnit Multiple Choice Questions & Answers (MCQs) focuses on “Testing the Controller Component”.
1. Improving the design of existing code is known as __________
a) Refactoring
b) Improving
c) Betterment
d) Upgrading
View Answer
Explanation: Refactoring is the process of restructuring existing code, changing the design.
2. In what order is multiple @Before annotated methods run?
a) Oldest First
b) Newest First
c) Randomly
d) According to argument list
View Answer
Explanation: It is not certain which @Before annotated method will run first as all run randomly.
3. The ___________ method confirms that both references are to the same object.
a) assertEquals
b) assertEqual
c) assertEqualObject
d) assertSame
View Answer
Explanation: assertSame uses the == operator to compare objects.
4. The assertEquals() method uses which underlying method to compare objects?
a) ==
b) equals()
c) isequal()
d) =
View Answer
Explanation: The assertEquals() method makes use of equals() to compare objects, comparing identity.
5. The equals() method is inherited from which base class?
a) Object
b) String
c) Integer
d) org.junit.Equals
View Answer
Explanation: The equals() method is inherited from the Objects class defined in java.lang.Object.
6. To use Parameterized.class with the @RunWith annotation, we need to import __________
a) org.junit.runners.Parameterized
b) org.junit.Parameterized
c) org.junit.runners.Parameterized
d) org.runners.Parameterized
View Answer
Explanation: The Parameterized.class is a part of the runner class of JUnit.
7. To avoid overdesigning an interface, usually ____________ is used.
a) Agile Development
b) Test Driven Development
c) Base Design Development
d) Waterfall Development
View Answer
Explanation: Since test driven development is reliant on a very short development cycle being repeated, it is used to avoid overdesigning an interface.
8. The _________ is a sequential or non-iterative design process, which is used in software development processes, in which progress is seen as flowing steadily downwards.
a) Waterfall Model
b) Iterative Model
c) Spiral Model
d) Big Bang Model
View Answer
Explanation: In a waterfall model, each phase or part must be completed before the next phase can begin and there is no overlapping between the phases.
9. Controller logic component accesses the ________ logic component.
a) Class
b) Object
c) Business
d) Criteria
View Answer
Explanation: Business logic component is responsible for the business logic and delegates data access.
10. Overuse of argument _________ can lead to fragile tests.
a) Parameters
b) Objects
c) Classes
d) Captors
View Answer
Explanation: The system under test is no longer a black box.
Sanfoundry Global Education & Learning Series – JUnit.
To practice all areas of Junit, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Check Programming Books
- Practice Programming MCQs
- Apply for Computer Science Internship
- Check JUnit Books