Explore topic-wise InterviewSolutions in .

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

1.

A layered application may have a front end to handle the presentation and a ______________ to execute the business logic.(a) Objects(b) Classes(c) Servlet(d) Back endI had been asked this question in an interview for job.My doubt stems from Unit Testing with Mock Objects topic in portion Testing with Mock Objects of JUnit

Answer» CORRECT answer is (d) Back END

The best explanation: The FRONT end is responsible for the presentation while the back end DEFINES the logic.
2.

For wrtiting favourable tests, __________ is perferred over inheritance.(a) Encapsulation(b) Polymorphism(c) Overloading(d) CompositionThis question was addressed to me during an online interview.Origin of the question is JMock topic in chapter Testing with Mock Objects of JUnit

Answer»

The correct option is (d) Composition

The EXPLANATION is: Composition is a BETTER code re-use mechanism.

3.

A profiler can look for _________ in an application.(a) Bottlenecks(b) Redundancies(c) Nodes(d) StatesI got this question during an interview.The question is from Refactoring with Mock Objects in division Testing with Mock Objects of JUnit

Answer»

Right choice is (a) BOTTLENECKS

To ELABORATE: The developer TRIES to OPTIMIZE the bottlenecks.

4.

The Cobertura command to run while checking coverage is ____________(a) cobertura-report.bat(b) cobertura-instrument.bat(c) cobertura-check.bat(d) cobertura-merge.batThis question was addressed to me in an online interview.Enquiry is from EasyMock in portion Testing with Mock Objects of JUnit

Answer»

Right answer is (c) cobertura-check.bat

Easy EXPLANATION: The cobertura-check.bat command is USED along with parameters to RUN REPORTING USING Cobertura.

5.

Developers often combine functional tests with __________ tests.(a) Unit(b) Integration(c) Stress(d) LossI had been asked this question in my homework.I need to ask this question from Unit Testing with Mock Objects in division Testing with Mock Objects of JUnit

Answer»

The correct answer is (B) Integration

Best EXPLANATION: Functional tests are so DESIGNED so as to COMBINE with integration tests EASILY.

6.

“cobertura-check.bat” is run ________ the JUnit tests to show which classes do not have adequate test coverage.(a) Before(b) After(c) Along with(d) Before and afterThis question was posed to me in homework.Origin of the question is EasyMock topic in chapter Testing with Mock Objects of JUnit

Answer»

The CORRECT option is (b) After

Explanation: This is used to check TEST COVERAGE and HENCE, can only be run after the JUNIT tests.

7.

____________ tests can control both the inputs to each method and the behaviour of secondary objects.(a) White Box(b) Unit(c) Black Box(d) LossI had been asked this question during an interview.I need to ask this question from Mocking an HTTP Connection topic in chapter Testing with Mock Objects of JUnit

Answer»

The correct option is (a) White BOX

The EXPLANATION is: Secondary OBJECTS LIKE mock objects and stubs are controlled by white box TESTS.

8.

In logic unit test, the boundaries of a given test can be controlled by using __________(a) Objects(b) Mock objects(c) Controllers(d) ModulesThe question was posed to me in semester exam.The query is from Refactoring with Mock Objects topic in chapter Testing with Mock Objects of JUnit

Answer»

The CORRECT option is (b) MOCK objects

For explanation: Mock objects HELP PERFORM specific tests by narrowing down to a specific TASK.

9.

The test instantiates ___________ and calls methods on these _________(a) Objects(b) Classes(c) Services(d) SubsystemsThe question was asked in unit test.The above asked question is from Unit Testing with Mock Objects topic in division Testing with Mock Objects of JUnit

Answer»

The CORRECT CHOICE is (a) Objects

To explain: The TEST CLASS has to be instantiated and objects are CREATED.

10.

The default value for the –datafile parameter is ____________(a) cobertura.ser(b) cobertura.dat(c) datafile.ser(d) cobertura.logThis question was addressed to me during an online interview.I want to ask this question from Using Mocks as Trojan Horses in section Testing with Mock Objects of JUnit

Answer»

The CORRECT choice is (a) cobertura.ser

To elaborate: The FILE is CREATED in the CURRENT directory.

11.

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 controlI had been asked this question in an interview for internship.This question is from Mock Objects topic in section Testing with Mock Objects of JUnit

Answer»

The correct CHOICE is (a) SLICING criterion

The BEST I can EXPLAIN: The slicing criterion is the point at which VALUES start being affected.

12.

The ___________ parameter specifies the minimum acceptable branch coverage rate needed by each class during Cobetura coverage checking.(a) datafile(b) branch(c) line(d) regexI had been asked this question in class test.The doubt is from EasyMock in division Testing with Mock Objects of JUnit

Answer»

Right ANSWER is (b) BRANCH

For explanation: The branch parameter should be an integer between 0 and 100.

13.

___________ specifies a regular expression to filter out certain lines of the source code.(a) −−datafile(b) −−destination(c) −−ignore(d) −−basedirThe question was asked at a job interview.This interesting question is from Using Mocks as Trojan Horses in portion Testing with Mock Objects of JUnit

Answer»

Correct OPTION is (c) −−ignore

Explanation: This is USEFUL for IGNORING LOGGING statements and for such the ignore parameter is used.

14.

While using Cobertura from the command line, which parameter specifies the base directory?(a) −−datafile(b) −−destination(c) −−ignore(d) −−basedirThis question was addressed to me in semester exam.I need to ask this question from Using Mocks as Trojan Horses topic in section Testing with Mock Objects of JUnit

Answer» RIGHT choice is (d) −−basedir

For explanation I would say: The –basedir parameter specifies the BASE DIRECTORY of the CLASS files that are to be instrumented.
15.

_________ is a free Java tool that calculates the percentage of code accessed by tests.(a) Cobertura(b) JUnit(c) XUnit(d) MavenI got this question during an interview for a job.Question is taken from Using Mocks as Trojan Horses topic in section Testing with Mock Objects of JUnit

Answer» RIGHT OPTION is (a) Cobertura

Best explanation: Cobertura is used to identify which parts of the Java program are LACKING test COVERAGE.
16.

________ tests are more difficult to write and run.(a) White Box(b) Unit(c) Black Box(d) LossThis question was addressed to me in an international level competition.The query is from Mocking an HTTP Connection in section Testing with Mock Objects of JUnit

Answer»

Correct option is (C) Black BOX

The EXPLANATION: Black box tests are difficult to write because they usually deal with a graphical front END.

17.

The test runs while a ___________ or EJB container hosts the application.(a) Objects(b) Classes(c) Servlet(d) SubsystemsThis question was posed to me in class test.I would like to ask this question from Unit Testing with Mock Objects topic in division Testing with Mock Objects of JUnit

Answer»

Correct CHOICE is (C) Servlet

To explain: The servlet attaches to any other EXTERNAL RESOURCE or device.

18.

__________ is an error condition hiding another error condition.(a) Fault Masking(b) Error Hiding(c) Redundant Masking(d) Fault GapingThis question was posed to me in an international level competition.Question is from Unit Testing with Mock Objects in portion Testing with Mock Objects of JUnit

Answer» CORRECT ANSWER is (a) Fault MASKING

Easy EXPLANATION: Fault Masking is a type of redundancy analysis.
19.

____________ 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 jumpsI have been asked this question in examination.The doubt is from Mock Objects in portion Testing with Mock Objects of JUnit

Answer»

The CORRECT OPTION is (a) LINEAR code SEQUENCE and jump

The best I can explain: Linear code sequence and jump helps to answer the question “how much testing is ENOUGH”?

20.

The JJ in JJ-path stands for ___________(a) Just Jump(b) Jump-in-JUnit(c) Java-JUnit(d) Jump-to-JumpThe question was posed to me in exam.My question is taken from Mock Objects in portion Testing with Mock Objects of JUnit

Answer»

Correct OPTION is (d) Jump-to-Jump

Easy EXPLANATION: Explanation: JJ-path or Jump-to-Jump-path is a well-defined LINEAR region of a PROGRAM’s CODE.

21.

_____________ more dependent on an external environment than pure unit tests are.(a) Logic unit test(b) Integration unit test(c) Functional unit test(d) Acceptance unit testThe question was posed to me in an interview.Asked question is from Refactoring with Mock Objects topic in chapter Testing with Mock Objects of JUnit

Answer»

Correct ANSWER is (C) Functional UNIT test

Best explanation: Functional Unit TESTS are not pure unit tests nor pure functional tests.

22.

Cobertura is based on ____________(a) JUnit(b) XUnit(c) Maven(d) JcoverageThe question was asked during an interview.Asked question is from Using Mocks as Trojan Horses in section Testing with Mock Objects of JUnit

Answer»

Correct choice is (d) JCOVERAGE

To elaborate: Jcoverage is an open source TOOL that ALLOWS to TEST the effectiveness of JAVA tests.

23.

At runtime, code can’t change a/an ___________ hierarchy.(a) Encapsulation(b) Polymorphism(c) Overloading(d) InheritenceI got this question during a job interview.My enquiry is from JMock in section Testing with Mock Objects of JUnit

Answer»

Correct OPTION is (d) Inheritence

The explanation: As CODE cannot change the hierarchy, objects NEEDS to be composed DIFFERENTLY.

24.

______________ is used to specify the name of the file to use for storing the metadata about the classes.(a) −−datafile(b) −−destination(c) −−ignore(d) −−basedirThe question was posed to me in class test.This intriguing question originated from Using Mocks as Trojan Horses in chapter Testing with Mock Objects of JUnit

Answer»

Correct answer is (a) −−datafile

To elaborate: The FILE SPECIFIES by –datafile is a single file CONTAINING SERIALIZED Java classes.

25.

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 testsThe question was asked in a job interview.I would like to ask this question from Mocking an HTTP Connection in chapter Testing with Mock Objects of JUnit

Answer»

Correct option is (a) ACCESS to more methods

Explanation: SINCE white box TESTS have KNOWLEDGE of the IMPLEMENTATION, they have access to more methods.

26.

A ___________ is a test that exercises code by focusing on a single method.(a) Logic unit test(b) Integration unit test(c) Functional unit test(d) Acceptance unit testI had been asked this question at a job interview.My doubt is from Refactoring with Mock Objects topic in division Testing with Mock Objects of JUnit

Answer»

The correct ANSWER is (a) Logic unit TEST

For explanation: Logic unit tests are a type of unit test that FOCUSES on a SINGLE method.

27.

The obvious drawback of a singleton is that it introduces _____________ into the application.(a) Redundancies(b) Errors(c) Global State(d) ModulesI had been asked this question in an interview.I need to ask this question from JMock topic in division Testing with Mock Objects of JUnit

Answer» CORRECT choice is (C) Global STATE

Explanation: The global state object can be ACCESSED by anyone.
28.

____________ parameter specifies the encoding used to read the source.(a) datafile(b) basedir(c) encoding(d) formatI have been asked this question in unit test.My question comes from EasyMock topic in portion Testing with Mock Objects of JUnit

Answer» RIGHT ANSWER is (c) encoding

The EXPLANATION is: During REPORTING with Cobertura, the encoding parameter defines the encoding of the files.
29.

______________ tests examine the code at the boundary of its public API.(a) Unit(b) Integration(c) Functional(d) LossThe question was posed to me in a job interview.The origin of the question is Unit Testing with Mock Objects in chapter Testing with Mock Objects of JUnit

Answer»

The CORRECT answer is (c) Functional

For explanation: This CORRESPONDS to testing APPLICATION use cases.

30.

A solution to reducing dependencies is to separate code between methods that instantiate new ____________ and methods that provide application logic.(a) Classes(b) Objects(c) Modules(d) FunctionsThis question was addressed to me by my college director while I was bunking the class.I'd like to ask this question from JMock in section Testing with Mock Objects of JUnit

Answer»

Correct answer is (b) OBJECTS

The BEST EXPLANATION: Separation of objects and logic leads to reduced DEPENDENCIES.

31.

Code that accesses a database has tests that effectively _________ the database.(a) Ignore(b) Delete(c) Call(d) DefineThe question was asked during an interview.The origin of the question is Refactoring with Mock Objects in division Testing with Mock Objects of JUnit

Answer» RIGHT choice is (c) Call

Easiest explanation: As a PART of integration unit TESTING, the TEST has to call the database to test its COMPONENTS.
32.

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) EliminateI have been asked this question in an interview.My question is from Mock Objects in division Testing with Mock Objects of JUnit

Answer»

The CORRECT CHOICE is (b) Backtrack

For EXPLANATION I would say: This type of DEBUGGING is known as backtracking.

33.

To get an expected test outcome a standard procedure is followed which is referred as ___________(a) Testing Mechanism(b) Testing Type(c) Test Cast(d) Test ScopeI had been asked this question during an interview.The question is from Unit Testing with Mock Objects in portion Testing with Mock Objects of JUnit

Answer» RIGHT OPTION is (b) Testing Type

The EXPLANATION is: Testing types include Unit testing, API testing among OTHERS.
34.

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 jumpI got this question in a job interview.I want to ask this question from Mock Objects in division Testing with Mock Objects of JUnit

Answer»

Correct choice is (b) LINEAR code SEQUENCE and jump

Explanation: LCSAJ is primarily used with dynamic software ANALYSIS.

35.

________________ is a design guideline that states that one class should know only as much as it needs to know.(a) Law of knowledge(b) Class laws(c) Law of Demeter(d) Action methodsI have been asked this question at a job interview.The above asked question is from JMock topic in portion Testing with Mock Objects of JUnit

Answer»

Right ANSWER is (c) Law of DEMETER

The best I can EXPLAIN: The law of demeter is also KNOWN as the Principle of LEAST Knowledge.

36.

The Cobertura command for merging datafiles is ________________(a) cobertura-report.bat(b) cobertura-instrument.bat(c) cobertura-check.bat(d) cobertura-merge.batThe question was asked in semester exam.The origin of the question is JMock topic in chapter Testing with Mock Objects of JUnit

Answer» CORRECT answer is (d) cobertura-merge.bat

To explain I would say: The cobertura-merge.bat command is USED along with parameters to run MERGING USING Cobertura.
37.

__________ are put in scope because they’re often useful as part of the battery of tests run in development.(a) Logic unit test(b) Integration unit test(c) Functional unit test(d) Acceptance unit testThe question was posed to me by my college director while I was bunking the class.My doubt stems from Refactoring with Mock Objects topic in chapter Testing with Mock Objects of JUnit

Answer»

Correct OPTION is (c) Functional unit test

For explanation: Functional unit tests are more DEPENDENT on an EXTERNAL ENVIRONMENT thanpure unit tests are.

38.

The default value of the format parameter is ____________(a) html(b) jar(c) java(d) datThe question was posed to me in an interview for internship.My question comes from EasyMock topic in portion Testing with Mock Objects of JUnit

Answer»

Correct CHOICE is (a) HTML

The explanation is: The HTML reports are made of annotated versions of each SOURCE file.

39.

In order to measure test coverage, Cobertura creates __________ of class files specified.(a) Instrumented copies(b) Objects(c) Mocks(d) ImagesThe question was posed to me in unit test.This intriguing question originated from Using Mocks as Trojan Horses topic in section Testing with Mock Objects of JUnit

Answer»

Correct choice is (a) Instrumented copies

Explanation: COBERTURA USES instrumented copies of the code to PROVIDE TEST COVERAGE.

40.

A _______________ is a test that extends the boundaries of integration unit testing to confirm a stimulus response.(a) Logic unit test(b) Integration unit test(c) Functional unit test(d) Acceptance unit testThis question was posed to me during an online interview.My question comes from Refactoring with Mock Objects topic in division Testing with Mock Objects of JUnit

Answer»

Correct CHOICE is (c) Functional UNIT TEST

Explanation: Afunctional unit test is a type of unit test which extends the boundaries of INTEGRATION tests.

41.

The ___________ parameter specifies the minimum acceptable line coverage rate needed by each class during Cobetura coverage checking.(a) datafile(b) branch(c) line(d) regexThis question was posed to me in an interview for job.This interesting question is from EasyMock in chapter Testing with Mock Objects of JUnit

Answer»

Right OPTION is (c) LINE

For EXPLANATION: The line PARAMETER should be an integer between 0 and 100.

42.

White box testing provides better test _________ than black box testing.(a) Result(b) Coverage(c) Mechanism(d) AcceptanceI have been asked this question in exam.My question is taken from Mocking an HTTP Connection in chapter Testing with Mock Objects of JUnit

Answer»

The correct answer is (B) COVERAGE

For explanation: White box TESTS COVER the INTERNAL working of the code leading to greater coverage of the system.

43.

White box testing provides better test _________ than black box testing.(a) Result(b) Coverage(c) Mechanism(d) AcceptanceI have been asked this question in examination.Query is from Mocking an HTTP Connection in chapter Testing with Mock Objects of JUnit

Answer»
44.

Layering provides __________ and the ability to access the back end with several different front ends.(a) Flexibility(b) Redundancy(c) Authorization(d) SimplicityThis question was addressed to me in a national level competition.This interesting question is from Unit Testing with Mock Objects topic in section Testing with Mock Objects of JUnit

Answer»

The correct ANSWER is (a) Flexibility

Easiest EXPLANATION: LAYERING allows to SEPARATE the logic from the PRESENTATION.

45.

Using ____________ testing, tests can be created that cover the public API of an application.(a) White Box(b) Unit(c) Black Box(d) LossThe question was posed to me in an international level competition.My doubt is from Mocking an HTTP Connection in portion Testing with Mock Objects of JUnit

Answer»

Correct choice is (c) Black Box

Easy EXPLANATION: As the DOCUMENTATION is used as the GUIDE, black box TESTS are written.

46.

___________ is used to add extra classes and jar files to Cobertura.(a) −−datafile(b) −−destination(c) −−ignore(d) −−auxClasspathThis question was addressed to me in an online quiz.I'm obligated to ask this question of Using Mocks as Trojan Horses topic in chapter Testing with Mock Objects of JUnit

Answer» CORRECT choice is (d) −−auxClasspath

To explain: This adds files that COBERTURA may have MISSED during instrumentation.
47.

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 definitionThe question was asked during an internship interview.This intriguing question originated from Mocking an HTTP Connection in division Testing with Mock Objects of JUnit

Answer» CORRECT answer is (a) Functional SPECIFICATION

For explanation: The FUNCTION specification TELLS the output and INPUT and not the internals.
48.

__________ 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 slicingI had been asked this question in my homework.This question is from Mock Objects in section Testing with Mock Objects of JUnit

Answer» RIGHT option is (c) Cause ELIMINATION

The BEST explanation: Cause elimination bases debugging on the basis of induction.
49.

The Cobertura command to run while reporting is ____________(a) cobertura-report.bat(b) cobertura-instrument.bat(c) cobertura-check.bat(d) cobertura-merge.batThe question was posed to me during an online exam.Question is taken from EasyMock in section Testing with Mock Objects of JUnit

Answer»

Correct answer is (a) COBERTURA-report.bat

The EXPLANATION: The cobertura-report.bat command is USED along with parameters to run reporting using Cobertura.

50.

Black box tests can bring more ________ than white box tests.(a) Value(b) Coverage(c) Mechanism(d) AcceptanceThe question was posed to me in an online quiz.Enquiry is from Mocking an HTTP Connection in section Testing with Mock Objects of JUnit

Answer» CORRECT ANSWER is (a) Value

The explanation: Since black BOX tests just check the external CHARACTERISTICS including input and output, they BRING more value.