Explore topic-wise MCQs in Junit.

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

1.

Which methods cannot be tested by JUnit test class?

A. public methods
B. private methods
C. protected methods
D. methods with void return type
Answer» C. protected methods
2.

What is a test runner?

A. Used to execute the test file
B. Defines the test file
C. Used to write test cases
D. Used to define annotations
Answer» B. Defines the test file
3.

What is the purpose of assertArrayEquals(“message”, A, B)?

A. Checks that “message” is in both A and B
B. Checks that “message” is in A but not B
C. Checks that “message” is in B but not A
D. Asserts the equality of the A and B arrays
Answer» E.
4.

WHAT_IS_A_TEST_RUNNER??$

A. Used to execute the test file
B. Defines the test file
C. Used to write test cases
D. Used to define annotations
Answer» B. Defines the test file
5.

Which_methods_cannot_be_tested_by_JUnit_test_class?$

A. public methods
B. private methods
C. protected methods
D. methods with void return type
Answer» C. protected methods
6.

Which annotation implies that a method is a JUnit test case?

A. @junit
B. @testcase
C. @org.Test
D. @org.junit.Test
Answer» E.
7.

What is the purpose of assertArrayEquals(“message”, A, B)?$

A. Checks that “message” is in both A and B
B. Checks that “message” is in A but not B
C. Checks that “message” is in B but not A
D. Asserts the equality of the A and B arrays
Answer» E.
8.

JUnit test files are written in files with which file extension?

A. .junit
B. .test
C. .java
D. .unit
Answer» D. .unit
9.

JUnit test methods must compulsorily return what value?

A. String
B. int
C. Object
D. void
Answer» E.
10.

What are fixtures in JUnit?

A. Objects that specify when to run a test
B. Fixed state of a set of objects used as a baseline for running tests
C. Bundle of few test cases run together
D. Date objects
Answer» C. Bundle of few test cases run together
11.

To use JUnit in a project we need to add which JAR files on our test classpath?

A. junit.jar
B. hamcrest-core.jar
C. junit.jar and hamcrest-core.jar
D. java-junit.jar
Answer» D. java-junit.jar
12.

A JUnit Unit Test Case is compulsorily characterised by a/an known _______ and a/an expected _____

A. output, input
B. input, output
C. variable, literal
D. program, variable
Answer» C. variable, literal
13.

JUnit is used for what type of software testing for the Java language?

A. Unit Testing
B. Integration Testing
C. Functional Testing
D. System Testing
Answer» B. Integration Testing