Java MCQ Number 01091

Java MCQ Set 1

1. The ____ package contains plugins that make it easier to use jMock with legacy code.
a) org.jmock.api
b) org.jmock.lib.action
c) org.jmock.lib.script
d) org.jmock.lib.legacy

Answer

Answer: d [Reason:] org.jmock.lib.legacy contains several plugins that make it suitable to use jMock with legacy code.

2. _______ class enables to imposterise abstract and concrete classes without calling the constructors of the mocked class.
a) ClassImposteriser
b) Imposteriser
c) ImposterisingClass
d) Imposter

Answer

Answer: a [Reason:] The ClassImposteriser implements Imposteriser interface.

3. ________ method reports if the Imposteriser is able to imposterise a given type.
a) canImposterise(Class<?> type)
b) Imposterise(Class<?> type)
c) imposterise(Invokable mockObject, Class<T> mockedType, Class<?>… ancilliaryTypes)
d) imposter()

Answer

Answer: a [Reason:] canImposterise(Class<?> type) returns true if this imposteriser can imposterise type, false otherwise.

4. _____ creates an imposter for a given type that forwards Invocations to an Invokable object.
a) canImposterise(Class<?> type)
b) Imposterise(Class<?> type)
c) imposterise(Invokable mockObject, Class<T> mockedType, Class<?>… ancilliaryTypes)
d) imposter()

Answer

Answer: c [Reason:] imposterise(Invokable mockObject, Class<T> mockedType, Class<?>… ancilliaryTypes) returns a new imposter. The imposter must implement the mockedType and all the ancialliaryTypes.

5. The mockObject parameter of imposterise() is the class representing the static type of the imposter.
a) True
b) False

Answer

Answer: b [Reason:] The mockType parameter of imposterise() is the class representing the static type of the imposter.

6. The ancilliaryTypes parameter of the imposterise() function must all be interfaces.
a) True
b) False

Answer

Answer: a [Reason:] The types must all be interfaces because Java only allows single inheritance of classes.

7. The ____ package contains plugins that make it easier to write custom actions by scripting their behaviour with BeanShell.
a) org.jmock.api
b) org.jmock.lib.action
c) org.jmock.lib.script
d) org.jmock.lib.legacy

Answer

Answer: c [Reason:] org.jmock.lib.script is the package containing plugins to write custom actions by scripting.

8. _____ class is an Action that executes a BeanShell script.
a) ScriptedAction
b) Scripted
c) Action
d) ScriptedActionClass

Answer

Answer: a [Reason:] ScriptedAction class makes it easy to implement custom actions.

9. ________ method performs an action in response to an invocation.
a) describeTo(Description description)
b) invoke(Invocation invocation)
c) perform(String script)
d) where(String name, Object value)

Answer

Answer: b [Reason:] invoke(Invocation invocation) returns the result of the invocation, if not throwing an exception.

10. The invoke method throws which exception?
a) ArrayIndexOutOfBounds
b) StringIndexOutOfBounds
c) Throwable
d) NullPointer

Answer

Answer: c [Reason:] Any checked exception thrown must be in the throws list of the invoked method.

Java MCQ Set 2

1. ______ translates ExpectationErrors into AssertionErrors that several test frameworks, including JUnit 4 and TestNG, use to report errors.
a) AssertionErrorTranslator
b) CamelCaseNamingScheme
c) CurrentStateMatcher
d) IdentityExpectationErrorTranslator

Answer

Answer: a [Reason:] The AssertionErrorTranslator is a class that translates ExpectationErrors into AssertionErrors.

2. ___ is a naming scheme wherein the implicit name for a mock object is the mocked type’s name with the first character represented in lower case.
a) AssertionErrorTranslator
b) CamelCaseNamingScheme
c) CurrentStateMatcher
d) IdentityExpectationErrorTranslator

Answer

Answer: b [Reason:] The CamelCaseNamingScheme is the class which defines a naming for mock objects.

3. ____ is an ExpectationErrorTranslator that doesn’t do any translation.
a) AssertionErrorTranslator
b) CamelCaseNamingScheme
c) CurrentStateMatcher
d) IdentityExpectationErrorTranslator

Answer

Answer: d [Reason:] IdentityExpectationErrorTranslator returns the ExpectationError it is given.

4. ____ is an Imposteriser that uses the Proxy class of the Java Reflection API.
a) AssertionErrorTranslator
b) CamelCaseNamingScheme
c) JavaReflectionImposteriser
d) IdentityExpectationErrorTranslator

Answer

Answer: c [Reason:] The JavaReflectionImposteriser class makes use of the Proxy class of the Java Reflection API.

5. _____ is a naming scheme in which the implicit name for a mock object is the last word of the mocked type’s name in lower case.
a) AssertionErrorTranslator
b) CamelCaseNamingScheme
c) JavaReflectionImposteriser
d) LastWordNamingScheme

Answer

Answer: d [Reason:] The LastWordNamingScheme class defines a naming scheme for mock objects.

6. ____ is a naming scheme in which the implicit name for a mock object is the mocked type’s name prepend with “mock”.
a) RetroNamingScheme
b) CamelCaseNamingScheme
c) JavaReflectionImposteriser
d) LastWordNamingScheme

Answer

Answer: a [Reason:] The RetroNamingScheme class defines a naming scheme with the prefix of “mock” for mock objects.

7. ____ function translates the given ExpectationError into an error type compatible with another testing framework.
a) change()
b) translate()
c) compatible()
d) mock()

Answer

Answer: b [Reason:] Translate() returns an error that is compatible with another testing framework and contains the same message and stack trace as the passed parameter.

8. _____ interface defines a sequence of expectations.
a) Sequence
b) States
c) Expectations
d) Mockery

Answer

Answer: a [Reason:] Invocations can be constrained to occur in a strict order defined by a sequence.

9. ____ is an interface which defines a state machine that is used to constrain the order of invocations.
a) Sequence
b) States
c) Expectations
d) Mockery

Answer

Answer: b [Reason:] The States interface defines the state machine.

10. ______ class represents the context, or neighborhood, of the object(s) under test.
a) Sequence
b) States
c) Expectations
d) Mockery

Answer

Answer: d [Reason:] The Mockery class represents the context under test.

Java MCQ Set 3

1. ______ translates ExpectationErrors into JUnit’s AssertionFailedErrors.
a) JUnit3ErrorTranslator
b) JUnit3Mockery
c) MockObjectTestCase
d) VerifyingTestCase

Answer

Answer: a [Reason:]JUnit3ErrorTranslator translate Expectation Errors into JUnit AssertionFailedErrors.

2. _____ is a Mockery that reports expectation errors as JUnit 3 test failures.
a) JUnit3ErrorTranslator
b) JUnit3Mockery
c) MockObjectTestCase
d) VerifyingTestCase

Answer

Answer: a [Reason:] JUnit3Mockery is used to report expectation errors.

3. ____ is a TestCase that supports testing with mock objects.
a) JUnit3ErrorTranslator
b) JUnit3Mockery
c) MockObjectTestCase
d) VerifyingTestCase

Answer

Answer: a [Reason:] MockObjectTestCase is used for testing mock objects.

4. ______ is a TestCase that verifies postconditions after the test has run and before the fixture has been torn down.
a) JUnit3ErrorTranslator
b) JUnit3Mockery
c) MockObjectTestCase
d) VerifyingTestCase

Answer

Answer: a [Reason:] VerifyingTestCase is a class that verifies post conditions.

5. To write a mock object test in JUnit 3, MockObject needs to be extended.
a) True
b) False

Answer

Answer: b [Reason:] To write a mock object test in JUnit 3, MockObjectTestCase needs to be extended.

6. A ___ is a JUnit Rule that manages JMock expectations and allowances.
a) JunitRuleMockery
b) JmockRuleMockery
c) JunitRule
d) JunitMockery

Answer

Answer: a [Reason:] JunitRuleMockery asserts that expectations have been met after each test has finished.

7. The ____ class provides factory methods for the executor services provided in the package.
a) Executors
b) Exceptions
c) ReadOnly
d) AbstractMock

Answer

Answer: a [Reason:] The Executors class has factory methods for the executor services.

8. A ____ offers services for the components it’s hosting, such as lifecycle, security, transaction, distribution, and so forth.
a) Component
b) Container
c) Mock
d) Appraisal

Answer

Answer: b [Reason:] A component executes in a container.

9. Stubs work well to ________ a given class for testing and asserting the state of its instances.
a) Delete
b) Enhance
c) Isolate
d) Append

Answer

Answer: c [Reason:] Stubbing a servlet container allows us to track how many requests were made, what the state of the server is, or what URL s where requested.

10. Stubs test the behavior of faked objects.
a) True
b) False

Answer

Answer: b [Reason:] In stubs, specialized methods are required to verify states.

Java MCQ Set 4

1. ________ is an adaptable process framework, intended to be tailored by the development organizations that will select the elements of the process that are appropriate for their needs.
a) RUP
b) AOP
c) FDD
d) XP

Answer

Answer: a [Reason:] Rup, which stands for Rational Unified Process, is the adaptable process framework.

2. UML stands for ___
a) Unknown Markup Language
b) Unified Modelling Language
c) Universal Markup Language
d) Universal Modelling Language

Answer

Answer: b [Reason:] UML is one tool that can be used to make the task of model visualization more feasible.

3. ________ describes a simple and easy to understand approach to developing business application software using agile techniques and concepts while still remaining true to the RUP.
a) RUPP
b) Scrum
c) AUP
d) EUP

Answer

Answer: c [Reason:] AUP, which stands for Agile Unified Process, applies agile techniques including test-driven development (TDD) and agile modelling (AM).

4. ______ is a methodology for modelling and documenting software systems based on best practices.
a) TDD
b) FDD
c) Scrum
d) AM

Answer

Answer: d [Reason:] Agile modelling is a collection of values and principles that can be applied on an (agile) software development project.

5. The discipline of AUP which deals with managing access to project artefacts is called ________
a) Model
b) Deployment
c) Project Management
d) Configuration Management

Answer

Answer: d [Reason:] Configuration management includes not only tracking artefact versions over time but also controlling and managing changes to them.

6. Random testing often known as ____ testing
a) Monkey
b) Amorous
c) Sporadic
d) Unknown

Answer

Answer: a [Reason:] The source of the name monkey testing comes from the infinite monkey theorem.

7. Monkey Testing is also included in Android Studio as part of the standard testing tools for ________
a) Unit Testing
b) Stress Testing
c) Functional Testing
d) Integration Testing

Answer

Answer: b [Reason:] Monkey testing is used to implement stress testing on the Android Studio.

8. ________ have no knowledge about the application or system in monkey testing.
a) Cloned Objects
b) Smart Monkey tests
c) Dumb Monkey tests
d) Fuzz tests

Answer

Answer: c [Reason:] Dumb monkey tests don’t know if their input or behaviour is valid or invalid.

9. Monkey testing is more about random actions while ____ testing is more about random data input.
a) Fuzz
b) Functional
c) Ad-hoc
d) Random

Answer

Answer: a [Reason:] While monkey testing uses randomized tests, fuzz uses randomized test data inputs.

10. Monkey testing is also different from _______ testing in that ad-hoc testing is performed without planning and documentation.
a) Fuzz
b) Functional
c) Ad-hoc
d) Random

Answer

Answer: c [Reason:] The objective of ad-hoc testing is to divide the system randomly into subparts and check their functionality.

Java MCQ Set 5

1. The ____ test relies exclusively on the external system interface to verify its correctness.
a) White Box
b) Unit
c) Black Box
d) Loss

Answer

Answer: c [Reason:] Black box tests have no knowledge of the internals of the code.

2. In black box testing, all that is needed to know in order to test the system properly is the system’s ________
a) Functional specification
b) Modularity
c) Redundancy
d) Class definition

Answer

Answer: a [Reason:] The function specification tells the output and input and not the internals.

3. White box testing is also known as ________
a) Black box testing
b) Sand box testing
c) Closed testing
d) Glass box testing

Answer

Answer: d [Reason:] White box requires the internals to be known just as a glass box shows what is inside.

4. White box testing provides better test ___ than black box testing.
a) Result
b) Coverage
c) Mechanism
d) Acceptance

Answer

Answer: b [Reason:] White box tests cover the internal working of the code leading to greater coverage of the system.

5. ________ tests are more difficult to write and run.
a) White Box
b) Unit
c) Black Box
d) Loss

Answer

Answer: c [Reason:] Black box tests are difficult to write because they usually deal with a graphical front end.

6. Black box tests can bring more ________ than white box tests.
a) Value
b) Coverage
c) Mechanism
d) Acceptance

Answer

Answer: a [Reason:] Since black box tests just check the external characteristics including input and output, they bring more value.

7. Using ______ testing, tests can be created that cover the public API of an application.
a) White Box
b) Unit
c) Black Box
d) Loss

Answer

Answer: c [Reason:] As the documentation is used as the guide, black box tests are written.

8. Higher test coverage is achieved by white box tests because of ______
a) Access to more methods
b) Better documentation
c) Faster tests
d) More accepted tests

Answer

Answer: a [Reason:] Since white box tests have knowledge of the implementation, they have access to more methods.

9. ______ tests can control both the inputs to each method and the behaviour of secondary objects.
a) White Box
b) Unit
c) Black Box
d) Loss

Answer

Answer: a [Reason:] Secondary objects like mock objects and stubs are controlled by white box tests.

10. White box unit tests can be written against ______ package-private, and public methods.
a) Static
b) Private
c) Protected
d) Void

Answer

Answer: c [Reason:] As white box unit tests cover protected methods too, they give more test coverage.

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.