Olete.in
Articles
Mock Tests
🧪 Maven MCQ Quiz Hub
Maven Mcq Set 2
Choose a topic to test your knowledge and improve your Maven skills
1. JUnit is used for what type of software testing for the Java language?
Unit Testing
Integration Testing
Functional Testing
System Testing
2. A JUnit Unit Test Case is compulsorily characterised by a/an known _______ and a/an expected _____
output, input
input, output
variable, literal
program, variable
3. To use JUnit in a project we need to add which JAR files on our test classpath?
junit.jar
hamcrest-core.jar
junit.jar and hamcrest-core.jar
java-junit.jar
4. What are fixtures in JUnit?
Objects that specify when to run a test
Fixed state of a set of objects used as a baseline for running tests
Bundle of few test cases run together
Date objects
5. JUnit test methods must compulsorily return what value?
String
int
Object
void
6. JUnit test files are written in files with which file extension?
.junit
.test
.java
.unit
7. What is the purpose of assertArrayEquals(“message”, A, B)?
Checks that “message” is in both A and B
Checks that “message” is in A but not B
Checks that “message” is in B but not A
Asserts the equality of the A and B arrays
8. Which annotation implies that a method is a JUnit test case?
@junit
@testcase
@org.Test
@org.junit.Test
9. What is a test runner?
Used to execute the test file
Defines the test file
Used to write test cases
Used to define annotations
10. Which methods cannot be tested by JUnit test class?
public methods
private methods
protected methods
methods with void return type
11. What are Parameterised tests used for in JUnit?
Run a test many times with different sets of parameters
Run a test with no parameters
Run a test with only String parameters
Run a test once with fixed set of parameters
12. A parameterised test class must carry which annotation?
@Test
@ParameterisedClass
@Runwith
@Class
13. The test class must carry the @RunWith annotation with the ______ class as its argument.
Default
Parameterised
Super
Inherited
14. What will be the outcome for the following piece of code? //The JUnit files are imported public class TestClass { @Test public void testingMethod() { String message = “Test”; assertEquals(3,message.length()); } }
Compilation Error
Runtime Error
Test Ran with Success
Test Ran with Failure
15. What does the fail() method do in JUnit?
Throws an assertion error unconditionally
Calls the default constructor
Outputs the message “Fail” to the console
Pauses the test for 1 second
16. Which annotation must be used to define suite classes?
@RunWith
@SuiteClasses
@Suite
@SuiteClass
17. When is the tearDown() method called in JUnit?
After all the tests have run
At the beginning of every test case
After each test case has run
At the beginning of the first test case
18. What does the assertTrue(“message”,A) do?
Asserts that the condition A is true
Asserts that “message” = A
Asserts that A contains “message”
Asserts that the condition A is false
19. How can a method be made to run before the execution of every test case?
Annotate the method with @Before
Prefix the method name with startfirst
Annotate the method with a @BeforeClass
Such a method cannot be made
20. Which method from TestCase class returns the name of a Test case?
String testCaseName()
String getTest()
String getTestCaseName()
String getName()
21. The ______ is a container used to gather tests for the purpose of grouping and invocation.
Result
TestCase
Suite
Test
22. What happens if the tester does not define a Suite?
The test runner automatically creates a Suite
Compilation Error
Every test fails
Every test passes
23. The Suite object is a _____ that executes all of the @Test annotated methods in the test class.
Result
FolderConfigurationTest
FileConfigurationTest
Runner
24. Suite class is the JUnit 4 equivalent of what feature of JUnit 3.8.x?
static Test suite() method
Test suite() method
static void suite() method
void suite() method
25. For a Suite class, the @RunWith annotation has the value of which class?
org.junit.runners.class
org.junit.Suite.class
org.runners.Suite.class
org.junit.runners.Suite.class
26. Which annotation is used to list all the classes in a suite?
@RunWith
@SuiteClasses
@Classses
@SuiteClass
27. If we want to run test files Test1 and Test2 together, the @SuiteClasses annotation will be?
@SuiteClasses(value={Test1.class,Test2.class})
@SuiteClasses(value=All)
@SuiteClasses(Test1, Test2);
@SuiteClasses()
28. JUnit Suites are independent of the capability of the ______ system.
Run
Class
Test
Build
29. Will the second and third assert failures be reported? public class TestFile { @Test public void testMethod() { assertTrue(false); assertTrue(false); assertTrue(false); } }
Yes
No
none
all the mentoined
30. Which attribute is added to the @Test annotation so that the test passes when an expected exception is thrown?
exception
throws
expected
expectedException
31. The ______ is a component that “interacts with a client, controlling and managing the handling of each request”.
Master
RequestHandler
Controller
Class
32. An example of a web controller is ____
Apache Struts Framework
JUnit
Java
Php
33. What are the object(s) which make the core of the description of a controller component?
The Request, the Response
The Request, the Response, the RequestHandler, and the Controller
The Request
The RequestHandler
34. What is the signature of the addHandler method of the Controller interface?
void addHandler(Request request, RequestHandler requestHandler)
void addHandler(RequestHandler requestHandler);
void addHandler(RequestHandler requestHandler);
void addHandler(Request request, Request requestHandler);
35. The principle of “Hollywood Principle: Don’t call us, we’ll call you” is commonly known as ______
Calling Principle
Control Call
Inversion of Control
No-Show Principle
36. Inversion of Control is used to increase __________ of the code.
Functionality
Cleanliness
Effectiveness
Modularity
37. When the container calls setter methods after invoking a constructor with no arguments it is known as _______
Constructor-based dependency injection
Setter-based dependency injection
Setter-Seller dependency injection
No-Constructor dependency injection
38. Constructor-based DI is accomplished when the container invokes a class constructor with ______
A number of arguments
No argument
Just one argument
Null objects
39. Constructor-based DI is preferred for ______
Optional dependencies
Mandatory dependencies
All dependencies
No dependency
40. In the context of unit testing, the term ___________ is used to contrast and compare the objects you use in your application with the objects that you use to test your application (test objects).
Mock Object
Dummy Object
Domain Object
Real Object
41. Improving the design of existing code is known as _______
Refactoring
Improving
Betterment
Upgrading
42. In what order is multiple @Before annotated methods run?
Oldest First
Newest First
Randomly
According to argument list
43. The ______ method confirms that both references are to the same object.
assertEquals
assertEqual
assertEqualObject
assertSame
44. The assertEquals() method uses which underlying method to compare objects?
==
equals()
isequal()
=
45. The equals() method is inherited from which base class?
Object
String
Integer
org.junit.Equals
46. To use Parameterized.class with the @RunWith annotation, we need to import ____
org.junit.runners.Parameterized
org.junit.Parameterized
org.junit.runners.Parameterized
org.runners.Parameterized
47. To avoid overdesigning an interface, usually ____________ is used.
Agile Development
Test Driven Development
Base Design Development
Waterfall Development
48. 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.
Waterfall Model
Iterative Model
Spiral Model
Big Bang Model
49. Controller logic component accesses the ________ logic component.
Class
Object
Business
Criteria
50. Overuse of argument _________ can lead to fragile tests.
Parameters
Objects
Classes
Captors
Submit