Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Servlet Wipro

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Which file in a Maven project defines dependencies, plugins, and build configuration?

a)

build.gradle

c)

pom.xml

d)

settings.xml

2.

Given a pom.xml, what will happen if a dependency is defined with <scope>provided</scope>?

a)

It will be packaged in the final JAR/WAR.

b)

Maven will fetch and include it from repository.

c)

It is required only during runtime.

d)

It won’t be packaged, assuming it’s provided by the runtime/container.

3.

You use a plugin in pom.xml but Maven throws "MojoExecutionException". What’s likely missing?

a)

JDK

b)

Plugin dependency

c)

Classpath

d)

Maven repository

4.

Which of the following goals is not a part of the Maven build lifecycle?

a)

validate

b)

package

c)

deploy

d)

merge

5.

What happens if you forget to declare <groupId> in your dependency?

a)

It’s optional

b)

Build fails

c)

Maven assumes “default” group

d)

Compilation succeeds but runtime fails

6.

You have this snippet in pom.xml:

What is its purpose?

a)

Downloads Java 11

b)

Configures Maven to use JDK 11 for compiling

c)

Specifies JVM version at runtime

d)
To define project dependencies.
7.

Which of the following servlet code snippets will lead to a thread-safety issue?

a)

This servlet is thread-safe

b)

Only causes issue if counter is static

c)

Not thread-safe, as counter is shared among threads

d)

Will throw compilation error

8.

What is the correct order of lifecycle methods in a servlet?

a)
service(), init(), destroy()
b)
init(), service(), destroy()
c)
init(), destroy(), service()
d)
destroy(), service(), init()
9.

Consider the following web.xml snippet. What does it do?

a)

Loads servlet lazily

b)

Loads servlet only when mapped URL is hit

c)

Loads servlet eagerly at startup

d)

Prevents servlet from being initialized

10.

In the doPost() method, if you don't set the content type before writing, what can happen?

a)

Response is blocked

b)

Browser displays garbled content

c)

Servlet gets restarted

d)

No issue at all

11.

Which method is never called by the servlet container?

a)
destroy()
b)
service()
c)
init()
d)

Constructor of servlet with parameters

12.

Which HTTP response status code best represents "Resource created"?

a)

201

b)

200

c)

204

d)

302

13.

What happens if you call sendRedirect("page.jsp") after response.getWriter().write("Hello")?

a)

Redirect will occur

b)

Output will be Hello and redirect will happen

c)

IllegalStateException will occur

d)

It will flush and stop the servlet

14.

In Servlet 3.0 annotations, which annotation is used to define a servlet?

a)
@WebComponent
b)
@WebServlet
c)
@ServletMapping
d)
@HttpServlet
15.

Which element is mandatory in a Maven pom.xml?

a)

<name>

b)

<description>

c)

<version>

d)

<url>