Java MCQ Number 01088

Java MCQ Set 1

1. ______ is a software analysis method used to identify structural units in code under test.
a) Linear code sequence and jump
b) State coverage
c) Lossless packs
d) Linear jumps

Answer

Answer: a [Reason:] Linear code sequence and jump helps to answer the question “how much testing is enough”?

2. LCSAJ stands for ___
a) Loading Code standard as Jumps
b) Linear code sequence and jump
c) Loading code sequence and jump
d) Linear coverage sequence and jump

Answer

Answer: b [Reason:] LCSAJ is primarily used with dynamic software analysis.

3. The JJ in JJ-path stands for _____
a) Just Jump
b) Jump-in-JUnit
c) Java-JUnit
d) Jump-to-Jump

Answer

Answer: d [Reason:] JJ-path or Jump-to-Jump-path is a well-defined linear region of a program’s code.

4. In a narrower sense, LCSAJ is also called ______
a) JJ-Path
b) Code Coverage
c) System Code Analysis
d) Code Breakdown

Answer

Answer: a [Reason:] LCSAJ is now always referred to as a JJ-path.

5. ______ is the most common and least efficient debugging technique.
a) Brute force debugging
b) Backtracking
c) Cause elimination
d) Program slicing

Answer

Answer: a [Reason:] In brute force debugging, all possible combinations are used and studied.

6. An effective method for locating errors in small programs is to _____ the incorrect results through the logic of the program until the point where the logic went astray is found.
a) Search
b) Backtrack
c) Slice
d) Eliminate

Answer

Answer: b [Reason:] This type of debugging is known as backtracking.

7. ____ involves the use of induction or deduction and introduces the concept of binary partitioning.
a) Brute force debugging
b) Backtracking
c) Cause elimination
d) Program slicing

Answer

Answer: c [Reason:] Cause elimination bases debugging on the basis of induction.

8. ____ is the computation of the set of programs statements.
a) Brute force debugging
b) Backtracking
c) Cause elimination
d) Program slicing

Answer

Answer: d [Reason:] The whole code is sliced into segments and their computation is known as Program Slicing.

9. The point at which the program slice affects the values at some point of interest is ____
a) Slicing criterion
b) Program criterion
c) Sliced Parts criterion
d) Information flow control

Answer

Answer: a [Reason:] The slicing criterion is the point at which values start being affected.

10. Program slicing can be used in ________ to locate source of errors more easily.
a) Testing
b) Coding
c) Debugging
d) Checking

Answer

Answer: c [Reason:] Program slicing is a debugging technique.

Java MCQ Set 2

1. A ________ is the second phase of software testing in which a sampling of the intended audience tests the product.
a) Alpha
b) Beta
c) Gamma
d) Delta

Answer

Answer: b [Reason:] Beta testing is done by the customer to test the product.

2. Beta Testing is also known as ___ testing.
a) Field
b) Unit
c) Functional
d) Box

Answer

Answer: a [Reason:] Beta testing is done at the customer’s location leading to it being also called field testing.

3. ________ beta versions are released to a select group of individuals for undergoing user test.
a) Open
b) Surround
c) Closed
d) Mandated

Answer

Answer: c [Reason:] The select group is invitation only to test the version and give feedback.

4. ________ is a parallel development of functions and subsequent integration.
a) AOP
b) OOP
c) Agile Development
d) RAD

Answer

Answer: d [Reason:] Components under RAD model are developed in parallel as if they were mini projects.

5. ______ can be thought of as a vehicle to perform a test process.
a) Testing technique
b) Testing tools
c) MoSCow
d) DRY

Answer

Answer: b [Reason:] The testing tools can be thought of as a resource to the tester, but is in itself insufficient to conduct testing.

6. In software testing, a _______ is a collection of software and test data configured to test a program unit by putting it under varying conditions and monitoring its behavior and output.
a) Test harness
b) Test automation
c) Test mechanics
d) Test manuscripts

Answer

Answer: a [Reason:] Test harnesses allow the automation of tests to be performed.

7. Test harness has two main parts, the test script repository and ___
a) Test specification
b) Test management controller
c) Test controller
d) Test execution engine

Answer

Answer: d [Reason:] A test execution engine is a type of software used to test complete or partial systems.

8. The test execution engine does not carry any information about the _____ product.
a) untested
b) tested
c) marketed
d) semi-tested

Answer

Answer: a [Reason:] Only the test specification and the test data has information about the tested product.

9. A ____ is an (often times virtual) environment used to verify the correctness soundness of a design or model, like that of a software product.
a) Test model
b) Test criteria
c) Test Flow
d) Test bench

Answer

Answer: d [Reason:] A test bench has an input, output, procedures to and procedures to check components.

10. _____ is a type of software testing which verifies that software, which was previously developed and tested, still performs correctly after it was changed or interfaced with other software.
a) Unit Testing
b) Regression Testing
c) Stress Testing
d) Functional Testing

Answer

Answer: b [Reason:] The purpose of regression testing is to ensure that changes have not introduced new faults.

Java MCQ Set 3

1. Mocks are Trojan horses because they replace real _____ from the inside, without the calling classes being aware of it.
a) Methods
b) Objects
c) Variables
d) Classes

Answer

Answer: b [Reason:] Mocks have access to internal information about the class, making them quite powerful.

2. When we’re talking about mock objects, a/an ___ is a feature built into the mock that verifies whether the external class calling this mock has the correct behavior.
a) Expectation
b) Explanation
c) Behavior
d) Amorous

Answer

Answer: a [Reason:] For example, a database connection mock could verify that the close method on the connection is called exactly once during any test that involves code using this mock.

3. EasyMock instantiates an object based on an interface or class.
a) True
b) False

Answer

Answer: a [Reason:] EasyMock is used to make mock objects which is based on the interface or class being called or extended.

4. EasyMock relies heavily on the ____import feature of Java.
a) Dynamic
b) Static
c) Class
d) Object

Answer

Answer: b [Reason:] All EasyMock imports are static imports.

5. To use the createMock method of EasyMock we need to import _____
a) org.easymock.EasyMock.createMock
b) org.EasyMock.createMock
c) org.easymock.createMock
d) org.createMock

Answer

Answer: a [Reason:] The EasyMock methods are found under “org.easymock.EasyMock.*”.

6. ____ method creates a mock object that implements the given interface, order checking is enabled by default.
a) createNiceControl
b) createMockBuilder
c) createNiceMock
d) createStrictMock

Answer

Answer: d [Reason:] createStrictMock is the old version of strictMock(String, Class), which is more completion friendly.

7. _____ is used for the creation of a mock object, with the specification of it being of the requested type, which has implementations of the given interface or extends the given class.
a) createMock(Class<T> toMock)
b) createMock(MockType type, Class<T> toMock)
c) createMock(String name, Class<T>toMock)
d) createMock(String name, MockType type, Class<T>toMock)

Answer

Answer: b [Reason:] createMock(MockType type, Class<T> toMock) is the old version of mock(MockType, Class), which is more completion friendly.

8. ______ creates a mock object, of the requested type and name which are passed, which also has implementations of the given interface or extends the given class.
a) createMock(Class <T> toMock)
b) createMock(MockType type, Class<T> toMock)
c) createMock(String name, Class<T> toMock)
d) createMock(String name, MockType type, Class<T> toMock)

Answer

Answer: d [Reason:] The name is passed as a parameter in the function definition.

9. ________ creates a mock object that implements the given interface with the specification is that order checking is disabled by default.
a) createMock(Class<T> toMock)
b) createMock(MockType type, Class<T>toMock)
c) createMock(String name, Class<T> toMock)
d) createMock(String name, MockType type, Class<T> toMock)

Answer

Answer: c [Reason:] The type parameter is the interface that the mock object should implement.

10. createMock(String name, Class<T> toMock) throws _____ exception.
a) IndexOutOfBounds
b) IllegalArgumentException
c) NullPointer
d) Arithmetic

Answer

Answer: b [Reason:] This exception is thrown when the name is not a valid Java identifier.

Java MCQ Set 4

1. ____ creates a mock builder allowing to create a partial mock for the given class or interface.
a) createMockBuilder(Class<T> toMock)
b) createMock(Class<T> toMock)
c) createNiceControl()
d) createNiceMock(Class<T> toMock)

Answer

Answer: a [Reason:] createMockBuilder(Class<T> toMock) is the old version of partialMockBuilder(Class), which is more completion friendly.

2. The ______ interface is used in the creation of partial mocks with EasyMock.
a) IMockBuilder<T>
b) IMocker<T>
c) IBuilder<T>expect(T value)
d) MockBuilder<T>

Answer

Answer: a [Reason:] The MockBuilder class implements the ImockBuilder<T> interface.

3. ______ creates a control of the requested type.
a) createControl()
b) createControl(MockType type)
c) createNiceControl()
d) createNiceMock(Class<T> toMock)

Answer

Answer: b [Reason:] createControl(MockType type) returns an ImocksControl object.

4. _______ returns the expectation setter for the last expected invocation in the current thread.
a) createControl()
b) createControl(MockType type)
c) createNiceControl()
d) expect(T value)

Answer

Answer: d [Reason:] The parameter value is used to transport the type to the ExpectationSetter.

5. anyObject() expects any double argument.
a) True
b) False

Answer

Answer: b [Reason:] anyObject() expects any object argument.

6. _______ expects a comparable argument greater than or equal the given value.
a) anyObject()
b) anyString()
c) geq(Comparable<T> value)
d) anyDouble()

Answer

Answer: c [Reason:] geq stands for greater than or equal.

7. By default, a mock is thread safe.
a) True
b) False

Answer

Answer: a [Reason:] Unless NOT_THREAD_SAFE_BY_DEFAULT is set, a mock is thread safe.

8. ________ create a new capture instance that will keep only the last captured value.
a) newCapture()
b) makeThreadSafe()
c) createNiceControl()
d) createNiceMock(Class<T> toMock)

Answer

Answer: a [Reason:] The newCapture method without arguments creates a new capture.

9. _______ reports an argument matcher.
a) newCapture()
b) makeThreadSafe()
c) reportMatcher(IArgumentMatcher matcher)
d) createNiceMock(Class<T> toMock)

Answer

Answer: c [Reason:] The reportMatcher method is used to report an argument matcher.

10. The ___ interface decides whether an actual argument is accepted.
a) IMockBuilder<T>
b) IMocker<T>
c) IBuilder<T>expect(T value)
d) IArgumentMatcher

Answer

Answer: d [Reason:] IargumentMatcher is a public interface which decides whether an actual argument is accepted.

Java MCQ Set 5

1. To implement a custom URL protocol handler, the URL method ____ is called.
a) setURLStreamHandlerFactory
b) setURLStreamFactory
c) setURLStreamHandlerFactorySetting
d) setStreamHandlerFactory

Answer

Answer: a [Reason:] A custom URLStreamHandlerFactory is passed to the setURLStreamHandlerFactory method.

2. ___ replace the objects with which the methods under test collaborate, offering a layer of isolation.
a) Classes
b) Mocks
c) Unified Stamps
d) Interfaces

Answer

Answer: b [Reason:] Mocks are similar to stubs because of the level of isolation they offer.

3. _______ are empty shells that supply methods to let the tests have control of the behavior of all the business methods of the faked class.
a) Stubs
b) Jetty
c) Mocks
d) Interfaces

Answer

Answer: c [Reason:] Mocks are different from stubs in the sense that they do not implement any logic.

4. The most important point to consider when writing a mock is that it shouldn’t have any ____.
a) Redundancy
b) Abstraction
c) Matchers
d) Business Logic

Answer

Answer: d [Reason:] Mocks must be a dumb object that does only what the test tells it to do.

5. Applying the ___ pattern to a class means removing the creation of all object instances for which this class isn’t directly responsible and passing any needed instances instead.
a) Message Passing
b) Inversion Of Control
c) Observer Pattern
d) Strategy Pattern

Answer

Answer: b [Reason:] The instances may be passed using a specific constructor, using a setter, or as parameters of the methods needing them.

6. ______ is an architectural pattern that stores in-memory object data in relational databases.
a) Active Record Pattern
b) Inversion Of Control
c) Observer Pattern
d) Strategy Pattern

Answer

Answer: a [Reason:] The active record pattern is an approach to accessing data in a database.

7. _______ in computer science is a programming technique for converting data between incompatible type systems.
a) Active Record Pattern
b) Inversion Of Control
c) Object Relational Mapping
d) Strategy Pattern

Answer

Answer: c [Reason:] Object Relational Mapping creates, in effect, a “virtual object database”.

8. The _____ is a software design pattern that allows the interface of an existing class to be used as another interface.
a) Adapter Pattern
b) Bridge Pattern
c) Decorator Pattern
d) Composite Pattern

Answer

Answer: a [Reason:] The Adapter design pattern allows otherwise incompatible classes to perform together by the conversion of the interface of one class into an interface expected by the clients.

9. The ___ is a design pattern that adds behavior to an individual object, either statically or dynamically, without affecting the behavior of other objects from the same class.
a) Adapter Pattern
b) Bridge Pattern
c) Decorator Pattern
d) Composite Pattern

Answer

Answer: c [Reason:] The decorator pattern is often useful for adhering to the Single Responsibility Principle.

10. The ______ is a design pattern in object-oriented programming that allows object composition to achieve the same code reuse as inheritance.
a) Adapter Pattern
b) Bridge Pattern
c) Decorator Pattern
d) Delegation Pattern

Answer

Answer: d [Reason:] In delegation, an object handles a request by delegating to a second object (the delegate).

ed010d383e1f191bdb025d5985cc03fc?s=120&d=mm&r=g

DistPub Team

Distance Publisher (DistPub.com) provide project writing help from year 2007 and provide writing and editing help to hundreds student every year.