Java MCQ Set 1
1. The review process for a particular review begins with a _______ by the author to the moderator in formal review.
a) Request For Review
b) Requirement Analysis
c) Notice For Review
d) Goal Design
Answer
Answer: a [Reason:] Planning forms the first step of a formal review which begins with a request for review.
2. Configuration management procedures be implemented during ______
a) Test Execution
b) Test Planning
c) Test Design
d) Test Success
Answer
Answer: b [Reason:] Configuration management procedures allow the testers to manage their testware and hence, should be implemented during test planning.
3. ________ is a process which is intended to reveal flaws in the security mechanisms of an information system that protect data and maintain functionality as intended.
a) Integrity Testing
b) Unit Testing
c) Security Testing
d) Stress testing
Answer
Answer: c [Reason:] Typical security requirements may include specific elements of confidentiality, integrity, availability, authentication, authorization and non-repudiation.
4. ___ of information refers to protecting information from being modified by unauthorized parties.
a) Confidentiality
b) Authentication
c) Authorization
d) Integrity
Answer
Answer: d [Reason:] Integrity of information is intended to allow the receiver to determine that the information provided by a system is correct.
5. ____ means to ensure that a transferred message has been sent and received by the intended parties who are claiming to have sent and received the message.
a) Confidentiality
b) Authentication
c) Non-repudiation
d) Integrity
Answer
Answer: c [Reason:] Non-repudiation is used to guarantee that the sender of a message cannot later deny having sent the message.
6. _______looks for known security issues by using automated tools to match conditions with known vulnerabilities.
a) Discovery
b) Vulnerability Scan
c) Security Assessment
d) Penetration Test
Answer
Answer: b [Reason:] Vulnerability scanning is supplemented with credential based scanning that remove some common false positives.
7. ____ uses discovery and vulnerability scanning to identify security vulnerabilities
a) Discovery
b) Vulnerability Scan
c) Vulnerability Assessment
d) Penetration Test
Answer
Answer: c [Reason:] Vulnerability Assessment places the findings into the context of the environment under test.
8. ___ is driven by an Audit or a Risk function to look at a specific control or compliance issue.
a) Security Audit
b) Vulnerability Scan
c) Vulnerability Assessment
d) Penetration Test
Answer
Answer: a [Reason:] Characterized by a narrow scope, Security audit is used to diagnose a compliance issue or specific control.
9. ____ simulates an attack by a malicious party.
a) Security Audit
b) Vulnerability Scan
c) Vulnerability Assessment
d) Penetration Test
Answer
Answer: d [Reason:] Penetration Test approach looks at the depth of attack in comparison to the Security Assessment approach.
10. ________ builds upon Vulnerability Assessment by adding manual verification to confirm exposure.
a) Security Audit
b) Security Assessment
c) Vulnerability Assessment
d) Penetration Test
Answer
Answer: b [Reason:] Security Assessment does not include the exploitation of vulnerabilities to gain further access.
Java MCQ Set 2
1. Using old tests to guard against new changes is a form of ________
a) Unit Testing
b) Integration Testing
c) Regression Testing
d) Loss Testing
Answer
Answer: c [Reason:] The best way to ensure that regression testing takes place is to automate the test suites.
2. A ________ is a piece of code that’s inserted at runtime in place of the real code.
a) Stub
b) Mock Object
c) Packet
d) Jammer
Answer
Answer: a [Reason:] Stubs are used in order to isolate the caller from the real implementation.
3. The intent of using stubs is to replace a ___ behaviour with a simpler one.
a) Unique
b) Complex
c) Redundant
d) Anomalous
Answer
Answer: b [Reason:] Stubs allow independent testing of some part of the real code.
4. Stubs usually provide high _______ in the tested system.
a) Mocking
b) Security
c) Confidence
d) Modularity
Answer
Answer: c [Reason:] With stubs, the objects under test aren’t getting modified.
5. Stubs don’t lend themselves well to ______ unit testing.
a) Fine-grained
b) Coarse-grained
c) Redundant
d) Functional
Answer
Answer: a [Reason:] In general, stubs are better adapted for replacing coarse-grained portions of code.
6. A build or developer usually executes tests involving stubs in their ___ environment.
a) Dead
b) Running
c) Production
d) Fake
Answer
Answer: b [Reason:] Executing in the running environment provides additional confidence.
7. An implementation that returns a hardcoded value for purposes of testing is known as a ____
a) Stub
b) Mock Object
c) Packet
d) Jammer
Answer
Answer: a [Reason:] A stub implementation can be created dynamically using lambdas.
8. _______ is a software testing technique that is useful to help in the generation of test data.
a) Symbolic Execution
b) Stubs
c) Active testing
d) All-pairs testing
Answer
Answer: a [Reason:] Symbolic Execution is used in proving the program quality.
9. The ________ identifies the decision points and the assignments associated with each flow.
a) Decision Table
b) Flowgraph
c) Testing Design
d) Audit
Answer
Answer: b [Reason:] Traversing the flow graph from an entry point is used to produce a list of assignment statements and branch predicates.
10. Symbolic execution is not able to proceed if the number of iterations in the loop is known.
a) True
b) False
Answer
Answer: a [Reason:] Symbolic execution can also not be used with arrays.
Java MCQ Set 3
1. The ______ is a component that “interacts with a client, controlling and managing the handling of each request”.
a) Master
b) RequestHandler
c) Controller
d) Class
Answer
Answer: c [Reason:] A controller is a component that “interacts with a client, controlling and managing the handling of each request,” and tells that it is used in both presentation-tier and business-tier patterns.
2. An example of a web controller is ____
a) Apache Struts Framework
b) JUnit
c) Java
d) Php
Answer
Answer: a [Reason:] Apache Struts Framework is an open source framework for building Servlet/JSP based web applications which is an example of a web controller.
3. What are the object(s) which make the core of the description of a controller component?
a) The Request, the Response
b) The Request, the Response, the RequestHandler, and the Controller
c) The Request
d) The RequestHandler
Answer
Answer: b [Reason:] The flow of control is from the Request interface to the Response interface to the RequestHandler interface finally to the Controller Interface.
4. What is the signature of the addHandler method of the Controller interface?
a) void addHandler(Request request, RequestHandler requestHandler)
b) void addHandler(RequestHandler requestHandler);
c) void addHandler(RequestHandler requestHandler);
d) void addHandler(Request request, Request requestHandler);
Answer
Answer: a [Reason:] The addHandler method takes a Request and then a RequestHandler to handle that request as parameters.
5. The principle of “Hollywood Principle: Don’t call us, we’ll call you” is commonly known as _______
a) Calling Principle
b) Control Call
c) Inversion of Control
d) No-Show Principle
Answer
Answer: c [Reason:] Inversion of Control focuses on separating what to do from when to do.
6. Inversion of Control is used to increase ____ of the code.
a) Functionality
b) Cleanliness
c) Effectiveness
d) Modularity
Answer
Answer: d [Reason:] Inversion of control makes the code more extensible resulting in more modular code.
7. When the container calls setter methods after invoking a constructor with no arguments it is known as ____
a) Constructor-based dependency injection
b) Setter-based dependency injection
c) Setter-Seller dependency injection
d) No-Constructor dependency injection
Answer
Answer: b [Reason:] Setter-based DI is accomplished by the container calling setter methods on your beans after invoking a no-argument constructor or no-argument static factory method.
8. Constructor-based DI is accomplished when the container invokes a class constructor with ______
a) A number of arguments
b) No argument
b) Just one argument
c) Null objects
Answer
Answer: a [Reason:] Each argument represents a dependency on some other class.
9. Constructor-based DI is preferred for _____
a) Optional dependencies
b) Mandatory dependencies
c) All dependencies
d) No dependency
Answer
Answer: b [Reason:] Since there has to be at least one argument, Constructor-based DI is preferred for Mandatory dependencies.
10. 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).
a) Mock Object
b) Dummy Object
c) Domain Object
d) Real Object
Answer
Answer: c [Reason:] Any object under test is considered a domain object.
Java MCQ Set 4
1. 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
Answer: a [Reason:] Unit testing is the testing of an individual unit or group of related units. That is precisely what JUnit is used for.
2. 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
Answer: b [Reason:] A JUnit Unit Test Case is characterized by a known input and an expected output, which is predefined. The known input tests a precondition and the expected output a post-condition.
3. 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
Answer: c [Reason:] hamcrest-core.jar has Matchers that JUnit uses for unit testing.
4. 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
Answer: b [Reason:] Tests need to run against the backdrop of set of predefined or known objects. This set of objects is called a test fixture.
5. JUnit test methods must compulsorily return what value?
a) String
b) int
c) Object
d) void
Answer
Answer: d [Reason:] If a JUnit test method is declared to return anything then file will compile successfully. But the execution will fail because JUnit requires all test methods to be declared to return void.
6. JUnit test files are written in files with which file extension?
a) .junit
b) .test
c) .java
d) .unit
Answer
Answer: c [Reason:] JUnit test files are regular java files with special methods which are referenced via annotations.
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
Answer: d [Reason:] Asserts the equality of the A and B arrays. The “message” is displayed to the user.
8. Which annotation implies that a method is a JUnit test case?
a) @junit
b) @testcase
c) @org.Test
d) @org.junit.Test
Answer
Answer: d [Reason:] Annotate a method with @org.junit.Test to imply that it is a JUnit test case.
9. 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
Answer: a [Reason:] Test runner is used for executing the test cases using the runClasses() method of JUnitCore class of JUnit to run the test case.
10. 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
Answer: b [Reason:] When a method is declared as “private”, it can only be accessed within the same class. So there is no way to test a “private” method of a target class from any test class.
Java MCQ Set 5
1. _____ is favoured over conditionals to better write testable code.
a) Polymorphism
b) Composition
c) Inheritance
d) Overloading
Answer
Answer: a [Reason:] More conditionals lead to more complex code.
2. _______ is a programming practice that expects new code to be written only if an automated test has failed and also to eliminate duplication.
a) Object Oriented Testing
b) Test Driven Development
c) Acceptance Testing
d) Lossless Development
Answer
Answer: b [Reason:] The goal of TDD is “clean code that works.”
3. API stands for ___
a) Application programming interface
b) Application programming instruction
c) Android programming interface
d) Application performance interface
Answer
Answer: a [Reason:] APIs are a set of functions and procedures that allow the creation of applications.
4. When the ___ is used as the method’s first client, it becomes easier to focus purely on the API.
a) Object
b) Class
c) Test
d) Stub
Answer
Answer: c [Reason:] This is an advantage of test driven development.
5. Eliminating duplication ensures that code is written that’s not only testable but also
_______
a) Erasable
b) Maintainable
c) Upgradeable
d) Changeable
Answer
Answer: b [Reason:] Code maintenance is enhanced by the elimination of duplication.
6. ________ platform builds the application from its various components.
a) Development platform
b) Integration platform
c) Acceptance platform
d) Stress test platform
Answer
Answer: b [Reason:] Integration platform ensures that all the components work together.
7. The _____ platform is the last staging area before production.
a) Development platform
b) Integration platform
c) Acceptance platform
d) Pre-production platform
Answer
Answer: d [Reason:] The pre-production platform is an optional platform before the production platform.
8. On the development platform, ___ unit tests are executed.
a) Acceptance
b) Lossless
c) Logic
d) Functional
Answer
Answer: c [Reason:] These are tests that can be executed in isolation from the environment.
9. The _______ exercises the application under load and verifies that it scales correctly.
a) Development platform
b) Integration platform
c) Acceptance platform
d) Stress test platform
Answer
Answer: d [Reason:] The scaling is done with respect to size and response time.
10. User feedback is got from the ________
a) Development platform
b) Integration platform
c) Acceptance platform
d) Stress test platform
Answer
Answer: c [Reason:] The acceptance platform is where the project’s customers accept (sign off on) the system.