Explore topic-wise MCQs in Junit.

This section includes 14 Mcqs, each offering curated multiple-choice questions to sharpen your Junit knowledge and support exam preparation. Choose a topic below to get started.

1.

The correct way to initialise an ExpectedException object is __________

A. public ExpectedException thrown = ExpectedException.none()
B. @Rule public ExpectedException thrown
C. @Rule public ExpectedException thrown = ExpectedException.none()
D. public ExpectedException thrown = ExpectedException.none()
Answer» D. public ExpectedException thrown = ExpectedException.none()
2.

ExpectedException is found under which package?

A. org.junit.ExpectedException
B. org.junit.Test.ExpectedException
C. org.junit.Rule.ExpectedException
D. org.junit.rules.ExpectedException
Answer» E.
3.

The _________ rule can be used to test both exception type and message.

A. Expected
B. ExpectedException
C. CatchException
D. Catch
Answer» C. CatchException
4.

With the ‘expected’ argument, one cannot ___________

A. Test a method
B. Test for exception type
C. Test the value of the message in the exception
D. Test for specific exception
Answer» D. Test for specific exception
5.

EXPECTEDEXCEPTION_IS_FOUND_UNDER_WHICH_PACKAGE??$

A. org.junit.ExpectedException
B. org.junit.Test.ExpectedException
C. org.junit.Rule.ExpectedException
D. org.junit.rules.ExpectedException
Answer» E.
6.

The_correct_way_to_initialise_an_ExpectedException_object_is___________$

A. public ExpectedException thrown = ExpectedException.none()
B. @Rule public ExpectedException thrown
C. @Rule public ExpectedException thrown = ExpectedException.none()
D. public ExpectedException thrown = ExpectedException.none()
Answer» D. public ExpectedException thrown = ExpectedException.none()
7.

The _________ rule can be used to test both exception type and message?

A. Expected
B. ExpectedException
C. CatchException
D. Catch
Answer» C. CatchException
8.

With the ‘expected’ argument, one cannot ___________$

A. Test a method
B. Test for exception type
C. Test the value of the message in the exception
D. Test for specific exception
Answer» D. Test for specific exception
9.

Custom JUnit rules can be created using ___________

A. TestRule Interface
B. CreateRule Interface
C. RuleCreate Interface
D. RuleInitialize Interface
Answer» B. CreateRule Interface
10.

AOP forms a basis for __________

A. Functional Development
B. Object Oriented Programming
C. Datafield Development
D. Aspect Oriented Software Development
Answer» E.
11.

________ describes a class of functions which when run modify other functions.

A. Class
B. Advice
C. Modifiers
D. Changers
Answer» C. Modifiers
12.

_________ is a programming paradigm which allows the separation of cross cutting concerns, hence, increasing modularity.

A. Functional Programming
B. Object Oriented Programming
C. Aspect Oriented Programming
D. Data Injections
Answer» D. Data Injections
13.

________ can be useful in adding additional functionality which applies to every test within a test class.

A. Copy
B. Rules
C. Exceptions
D. Boundaries
Answer» C. Exceptions
14.

What are exceptions?

A. Anomalous conditions requiring special processing
B. Extra methods written to increase functionality
C. Commented lines describing exceptional cases
D. Null objects
Answer» B. Extra methods written to increase functionality