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.

_____________ 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 DevelopmentThis question was posed to me during a job interview.This intriguing question originated from Limitations of Standard Unit Testing topic in section In-container Testing of JUnit

Answer»

The correct ANSWER is (B) TEST Driven Development

Explanation: The goal of TDD is “clean CODE that works.”

2.

_____________ 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 PatternI had been asked this question in an interview for job.Question is taken from Comparing Stubs, Mock Objects and In-container Testing in chapter In-container Testing of JUnit

Answer»

Right CHOICE is (c) Object RELATIONAL Mapping

For EXPLANATION I would say: Object Relational Mapping creates, in effect, a “virtual object database”.

3.

To create a Jetty context object, we have to import _____________(a) org.mortbay.jetty.Context;(b) org.jetty.Context;(c) org.mortbay.jetty.servlet.Context;(d) org.junit.Server;I have been asked this question in semester exam.I'd like to ask this question from In-container Testing topic in section In-container Testing of JUnit

Answer» CORRECT option is (c) org.mortbay.jetty.servlet.Context;

To explain: The Jetty SERVER is FOUND in “org.mortbay.jetty.servlet.Context”.
4.

When unit testing, it’s important to be able to control as much as possible of the environment in which the tests execute.(a) True(b) FalseThis question was addressed to me in a national level competition.This is a very interesting question from In-container Testing topic in chapter In-container Testing of JUnit

Answer»

Correct choice is (a) True

Explanation: This ENSURES that the TEST results are REPRODUCIBLE.

5.

The ______________ identifies the decision points and the assignments associated with each flow.(a) Decision Table(b) Flowgraph(c) Testing Design(d) AuditI had been asked this question by my school principal while I was bunking the class.Question is taken from The Mock Objects Solution topic in division In-container Testing of JUnit

Answer»

The CORRECT choice is (b) Flowgraph

To explain: Traversing the FLOW GRAPH from an entry POINT is used to produce a LIST of assignment statements and branch predicates.

6.

The intent of using stubs is to replace a _________ behaviour with a simpler one.(a) Unique(b) Complex(c) Redundant(d) AnomalousThe question was asked in an online interview.My question comes from The Mock Objects Solution topic in chapter In-container Testing of JUnit

Answer»

Right answer is (B) Complex

To EXPLAIN: Stubs allow independent testing of some PART of the real CODE.

7.

The _____________ exercises the application under load and verifies that it scales correctly.(a) Development platform(b) Integration platform(c) Acceptance platform(d) Stress test platformI have been asked this question by my college director while I was bunking the class.Question is from Limitations of Standard Unit Testing in section In-container Testing of JUnit

Answer»

Correct OPTION is (d) Stress test platform

Easy EXPLANATION: The SCALING is done with respect to size and RESPONSE time.

8.

A _____________ handler is attached to the root to serve files from the file system.(a) SourceHandler(b) ResourceHandler(c) AttachHandler(d) RootHandlerThis question was addressed to me during a job interview.This interesting question is from In-container Testing topic in division In-container Testing of JUnit

Answer» CORRECT option is (B) ResourceHandler

To explain I WOULD say: The ResourceHandler is ATTACHED to serve files from the file system.
9.

___________ is favoured over conditionals to better write testable code.(a) Polymorphism(b) Composition(c) Inheritance(d) OverloadingThe question was asked in final exam.The origin of the question is Limitations of Standard Unit Testing in chapter In-container Testing of JUnit

Answer» RIGHT choice is (a) Polymorphism

To explain I WOULD SAY: More CONDITIONALS lead to more complex CODE.
10.

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 LogicThis question was posed to me in homework.My enquiry is from Comparing Stubs, Mock Objects and In-container Testing topic in portion In-container Testing of JUnit

Answer»

The correct option is (d) BUSINESS Logic

To EXPLAIN: Mocks must be a DUMB object that does only what the test TELLS it to do.

11.

_____________ 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) InterfacesThis question was posed to me in exam.The doubt is from Comparing Stubs, Mock Objects and In-container Testing in division In-container Testing of JUnit

Answer»

The correct option is (c) MOCKS

Best explanation: Mocks are different from stubs in the SENSE that they do not implement any LOGIC.

12.

Jetty was originally called ________________(a) Eclipse(b) Maven(c) Ant(d) IssueTrackerThe question was asked by my school teacher while I was bunking the class.Query is from In-container Testing in division In-container Testing of JUnit

Answer»

Right option is (d) ISSUETRACKER

The EXPLANATION: Jetty was originally KNOWN as IssueTracker as that was its original application.

13.

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 PatternThis question was addressed to me during an interview.I want to ask this question from Comparing Stubs, Mock Objects and In-container Testing topic in section In-container Testing of JUnit

Answer»

Right option is (c) DECORATOR Pattern

The explanation: The decorator pattern is OFTEN USEFUL for adhering to the SINGLE RESPONSIBILITY Principle.

14.

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 PatternI had been asked this question in an interview.I'd like to ask this question from Comparing Stubs, Mock Objects and In-container Testing in division In-container Testing of JUnit

Answer»

Right answer is (a) ADAPTER Pattern

For explanation I would say: 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.

15.

_________ replace the objects with which the methods under test collaborate, offering a layer of isolation.(a) Classes(b) Mocks(c) Unified Stamps(d) InterfacesThe question was asked by my college director while I was bunking the class.My question is taken from Comparing Stubs, Mock Objects and In-container Testing topic in section In-container Testing of JUnit

Answer»

The CORRECT ANSWER is (b) Mocks

Explanation: Mocks are SIMILAR to STUBS because of the level of isolation they offer.

16.

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 PatternI have been asked this question by my school principal while I was bunking the class.My question is from Comparing Stubs, Mock Objects and In-container Testing in section In-container Testing of JUnit

Answer»

Right CHOICE is (b) Inversion Of Control

Easy explanation: The instances MAY be passed using a specific CONSTRUCTOR, using a SETTER, or as parameters of the methods needing them.

17.

Stubs don’t lend themselves well to ____________ unit testing.(a) Fine-grained(b) Coarse-grained(c) Redundant(d) FunctionalThe question was posed to me during an online interview.My question comes from The Mock Objects Solution topic in chapter In-container Testing of JUnit

Answer»

Correct OPTION is (a) Fine-grained

To explain I would say: In GENERAL, stubs are BETTER adapted for replacing coarse-grained PORTIONS of code.

18.

____________ 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 PatternI got this question during an interview.Asked question is from Comparing Stubs, Mock Objects and In-container Testing topic in section In-container Testing of JUnit

Answer»

Correct ANSWER is (a) Active Record Pattern

Explanation: The active record pattern is an approach to accessing DATA in a DATABASE.

19.

Stubs usually provide high _____________ in the tested system.(a) Mocking(b) Security(c) Confidence(d) ModularityI had been asked this question by my school teacher while I was bunking the class.My question is from The Mock Objects Solution topic in division In-container Testing of JUnit

Answer» RIGHT answer is (c) Confidence

To explain I WOULD say: With stubs, the OBJECTS under test aren’t getting modified.
20.

The ___________ platform is the last staging area before production.(a) Development platform(b) Integration platform(c) Acceptance platform(d) Pre-production platformI have been asked this question in an interview.Query is from Limitations of Standard Unit Testing topic in chapter In-container Testing of JUnit

Answer» CORRECT option is (d) Pre-production platform

To ELABORATE: The pre-production platform is an optional platform before the production platform.
21.

________ platform builds the application from its various components.(a) Development platform(b) Integration platform(c) Acceptance platform(d) Stress test platformThe question was asked in an interview.This interesting question is from Limitations of Standard Unit Testing topic in chapter In-container Testing of JUnit

Answer»

Correct OPTION is (B) INTEGRATION platform

The best I can explain: Integration platform ensures that all the COMPONENTS work together.

22.

To implement a custom URL protocol handler, the URL method __________ is called.(a) setURLStreamHandlerFactory(b) setURLStreamFactory(c) setURLStreamHandlerFactorySetting(d) setStreamHandlerFactoryI got this question in a job interview.I would like to ask this question from Comparing Stubs, Mock Objects and In-container Testing in section In-container Testing of JUnit

Answer»

Right option is (a) SETURLSTREAMHANDLERFACTORY

Explanation: A CUSTOM URLStreamHandlerFactory is passed to the setURLStreamHandlerFactory method.

23.

To create a Jetty server object, we have to import _____________(a) org.mortbay.jetty.Server;(b) org.jetty.Server;(c) org.junit.jetty.Server;(d) org.junit.Server;I got this question in an interview for job.This key question is from In-container Testing in portion In-container Testing of JUnit

Answer» CORRECT option is (a) org.mortbay.JETTY.SERVER;

EASIEST explanation: The Jetty Server is FOUND in “org.mortbay.jetty.Server”.
24.

API stands for _______________(a) Application programming interface(b) Application programming instruction(c) Android programming interface(d) Application performance interfaceThis question was addressed to me during an interview for a job.The query is from Limitations of Standard Unit Testing topic in division In-container Testing of JUnit

Answer»

Right answer is (a) Application programming interface

For explanation I would say: APIS are a set of FUNCTIONS and procedures that allow the CREATION of APPLICATIONS.

25.

While creating a server object like- Server obj = new Server(8080), 8080 represents the number of connections.(a) True(b) FalseI got this question by my college professor while I was bunking the class.Origin of the question is In-container Testing in chapter In-container Testing of JUnit

Answer»

The correct ANSWER is (B) False

For explanation: The PARAMETER of the constructor, in this CASE 8080, represents the port NUMBER.

26.

In Jetty, ____________ object processes the HTTP requests.(a) Server(b) Context(c) Root(d) HandlerI have been asked this question by my school principal while I was bunking the class.I'd like to ask this question from In-container Testing in section In-container Testing of JUnit

Answer»

The correct answer is (b) Context

The BEST EXPLANATION: Context object PROCESSES the HTTP requests and passes them to VARIOUS handlers.

27.

On the development platform, _________ unit tests are executed.(a) Acceptance(b) Lossless(c) Logic(d) FunctionalThis question was addressed to me in semester exam.I'd like to ask this question from Limitations of Standard Unit Testing topic in division In-container Testing of JUnit

Answer»

The correct OPTION is (c) Logic

The BEST I can EXPLAIN: These are tests that can be EXECUTED in isolation from the environment.

28.

Using old tests to guard against new changes is a form of ______________(a) Unit Testing(b) Integration Testing(c) Regression Testing(d) Loss TestingThe question was posed to me during an interview.I'm obligated to ask this question of The Mock Objects Solution topic in section In-container Testing of JUnit

Answer»

The correct OPTION is (c) Regression Testing

To EXPLAIN: The best way to ensure that regression testing takes place is to AUTOMATE the test SUITES.

29.

The ______________ method sets the document root from which to serve resources.(a) setResourceBase(b) resourceBase(c) setResource(d) setBaseThe question was asked by my school teacher while I was bunking the class.I'd like to ask this question from In-container Testing in portion In-container Testing of JUnit

Answer»

The CORRECT choice is (a) setResourceBase

For explanation I would SAY: The setResourceBase method is used to set the document root from which RESOURCES will be served.

30.

An implementation that returns a hardcoded value for purposes of testing is known as a __________(a) Stub(b) Mock Object(c) Packet(d) JammerThe question was asked during an interview.My question is from The Mock Objects Solution topic in chapter In-container Testing of JUnit

Answer» RIGHT option is (a) Stub

For explanation: A stub implementation can be CREATED DYNAMICALLY USING LAMBDAS.
31.

_______________ is a Java HTTP (Web) server and Java Servlet container.(a) Maven(b) Ant(c) Jetty(d) ZimbraI have been asked this question in a job interview.The above asked question is from In-container Testing in portion In-container Testing of JUnit

Answer»

The correct option is (c) Jetty

The BEST I can EXPLAIN: Jetty is OFTEN used for MACHINE to machine communications, usually WITHIN larger software frameworks.

32.

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) StubI had been asked this question during an online exam.I want to ask this question from Limitations of Standard Unit Testing in section In-container Testing of JUnit

Answer»

Right ANSWER is (C) Test

To elaborate: This is an ADVANTAGE of test driven DEVELOPMENT.

33.

_____________ 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 testingThis question was addressed to me by my college professor while I was bunking the class.Question is taken from The Mock Objects Solution in chapter In-container Testing of JUnit

Answer» RIGHT option is (a) Symbolic Execution

Easiest EXPLANATION: Symbolic Execution is used in PROVING the PROGRAM quality.
34.

A build or developer usually executes tests involving stubs in their _________ environment.(a) Dead(b) Running(c) Production(d) FakeThis question was addressed to me in final exam.My question is from The Mock Objects Solution in chapter In-container Testing of JUnit

Answer»

Correct choice is (b) RUNNING

The explanation: EXECUTING in the running ENVIRONMENT provides ADDITIONAL confidence.

35.

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) JammerThe question was posed to me in an online quiz.This interesting question is from The Mock Objects Solution topic in section In-container Testing of JUnit

Answer» CORRECT ANSWER is (a) Stub

Explanation: STUBS are used in order to isolate the CALLER from the real IMPLEMENTATION.