JUnit Questions and Answers – Testing the Controller Component

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 __________
a) Refactoring
b) Improving
c) Betterment
d) Upgrading
View Answer

Answer: a
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

Answer: c
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

Answer: d
Explanation: assertSame uses the == operator to compare objects.
advertisement
advertisement

4. The assertEquals() method uses which underlying method to compare objects?
a) ==
b) equals()
c) isequal()
d) =
View Answer

Answer: b
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

Answer: a
Explanation: The equals() method is inherited from the Objects class defined in java.lang.Object.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

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

Answer: a
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

Answer: b
Explanation: Since test driven development is reliant on a very short development cycle being repeated, it is used to avoid overdesigning an interface.
advertisement

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

Answer: a
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

Answer: c
Explanation: Business logic component is responsible for the business logic and delegates data access.
advertisement

10. Overuse of argument _________ can lead to fragile tests.
a) Parameters
b) Objects
c) Classes
d) Captors
View Answer

Answer: d
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.

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.