This set of JUnit Interview Questions and Answers for Experienced people focuses on “Testing the Controller Component”.
1. Improving the design of existing code is known as __________
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
d) According to argument list
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.
Explanation: assertSame uses the == operator to compare objects.
4. The assertEquals() method uses which underlying method to compare objects?
Explanation: The assertEquals() method makes use of equals() to compare objects, comparing identity.
5. The equals() method is inherited from which base class?
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 __________
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
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
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.
Explanation: Business logic component is responsible for the business logic and delegates data access.
10. Overuse of argument _________ can lead to fragile tests.
Explanation: The system under test is no longer a black box.
Sanfoundry Global Education & Learning Series – JUnit.
To practice all areas of JUnit for Interviews, here is complete set of 1000+ Multiple Choice Questions and Answers.