wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Full Stack Test 24-03-2025

Total questions: 100

Worksheet time: 1hrs 15mins

Name
Class
Date
1.

where can you keep .java files in webapplication(Servlets)?

a)

root directory

b)

WEB-INF

c)

src

d)

classes

2.
who dose control life cycle of servlet
a)
browser
b)
client
c)
container
d)
user
3.

The _______ specification defines an application programming interface for communication between the server and the application program

a)

Java Servlet

b)

java jdbc

c)

java applet

d)

java swing

4.

Which packages represent interfaces and classes for servlet API?

a)

javax.servlet

b)

javax.servlet.http

c)

both 1 and 2

d)

none of the above

5.

What is the lifecycle of a servlet?

a)

Servlet class is loaded

b)

Servlet instance is created

c)

init(),service() and destroy() methods will be called

d)

All the above

6.

How many times init() method is called during life time of a servlet?

a)

two times

b)

one time

c)

several times

d)

never called

7.

How many time destroy() method will be called during the life time of a Servlet?

a)

one

b)

two

c)

several time

d)

never called

8.

When will call init() method of a servlet?

(a)  

9.

When destroy method() of servlet called ?

a)

for first request

b)

when you close the browser window

c)

when you remove the application from server

d)

none of the above

10.

web.xml file is available in which directory of web application.

a)

root directory

b)

WEB-INF directory

c)

src

d)

classes

11.

where can you keep .java files in webapplication(Servlets)?

a)

root directory

b)

WEB-INF

c)

src

d)

classes

12.

All html pages will be placed in ----------- directory

a)

root directory

b)

WEB-INF

c)

src

d)

classes

13.

web.xml is also called as --------------------

a)

data directory

b)

deployment descriptor

c)

directroy descriptor

d)

none of the above

14.

what is root tag of web.xml ?

a)

web-app

b)

servlet

c)

servlet-mapping

d)

init-param

15.

under which tag of web.xml file contains actual servlet class

a)

web-app

b)

init-param

c)

servlet

d)

servlet-mapping

16.

Where to place user defined webapplications in webserver (Apache Tomcat)

a)

in bin directory

b)

in lib directory

c)

webapps directory

d)

work directory

17.

In which jar file contains the entire servlet API

a)

servlet-api.jar

b)

catalina.jar

c)

tomcat-api.jar

d)

jasper.jar

18.

What are the methods of ServletConfig Interface?

a)

getInitParameter()

b)

getServletName()

c)

getServletContext()

d)

all the above

19.

What are the parameters of the service() method

a)

ServletConfig,ServletContext

b)

doGet,doPost

c)

init-param

d)

ServletRequest,ServletResponse

20.

What is the parent tag of url-pattern tag in web.xml?

a)

servlet tag

b)

webapp tag

c)

servlet-mapping tag

d)

none of the above

21.

What are the methods of RequestDispatcher Interface?

a)

doGet(),doPost()

b)

include(),forward()

c)

backward(),doHead()

d)

doLink(),return

22.

How many types of cookies are available in servlets?

a)

2

b)

4

c)

8

d)

6

23.

doGet(),doPost() methods are available in which class ?

a)

GenericServlet

b)

HttpServlet

c)

Both 1 & 2

d)

None of the above

24.

How many Ways to we create Sessions?

a)

2

b)

6

c)

8

d)

4

25.

What are the different Exceptions thrown by service() method?

(a)  

26.

What are the different types of Cookies?

a)

writecookie, tempcookies

b)

strongcookie,weekcookies

c)

persistent,non-persistent

d)

none of the above

27.

JSP stands for __________.

a)

Java Server Page

b)

Java Second Page

c)

Java Service Page

d)

Java Spring Page

28.
Which of the following is used to declare instance variable through JSP Page?
a)
<% int iVar=0; %>
b)
<%! int iVar=0; %>
c)
<%! int iVar=0 %>
d)
<%= int iVar=0; %>
29.

Which method is used to register a jdbc driver?

a)

Class.ForName()

b)

Class.forName()

c)

class.ForName()

d)

class.forName()

30.

Java Server Pages (JSP) is a ------------------------------

a)

client-side programming technology

b)

server-side programming technology

c)

Both

31.

Which of the following is syntax of Expression Tag?

a)

<% Expression %>

b)

<%= Expression %>

c)

<& Expression &>

d)

<%! Expression %>

32.

4. In the below statement, which type of query can be used with executeUpdate( ) method. statement.executeUpdate (query here)?

a)

Insert, Update, Delete

b)

Insert, Select, Delete

c)

Only Select

d)

Any Query

33.

Which method of HttpServletRequest is used to read the value of HTML form elements

a)

getValue()

b)

getInputText()

c)

getParameter()

d)

getAttributes()

34.

which of the following are methods of user request handling in servlet

a)

doGet()

b)

doPost()

c)

Both of them

d)

None of these

35.

•Servlet is an ---------------- that must be implemented for creating any Servlet.

a)

interface

b)

class

c)

method

d)

variable

36.

Which of these interface declares core method that all collections will have?

a)

Collection

b)

EventListner

c)

Comparator

d)

Set

e)

List

37.

What is the purpose of the List interface in Java?

a)

To store and maintain an ordered collection

b)

To provide index-based methods for manipulating elements

c)

To accommodate duplicate elements and store null elements

d)

To iterate the list in both forwards and backwards directions

38.

Which of the following is an implementation class of the List interface?

a)

ArrayList

b)

StringList

c)

Stack

d)

Vector

39.

Which of the following is an implementation class of the Set interface?

a)

HashSet

b)

LinkedHashSet

c)

ArrayList

d)

LinkedList

40.

What is the main difference between List and Set interfaces?

a)

List is an ordered sequence, while Set is an unordered sequence

b)

List allows the inclusion of duplicate elements, while Set does not

c)

List allows position access to elements, while Set does not

d)

List can store multiple null elements, while Set can only store one

41.

What is Collection in Java?

a)

A group of objects

b)

A group of classes

c)

A group of interfaces

d)

None of the mentioned

42.
Which of these collection class has the ability to grow dynamically?
a)
Array
b)
Arrays
c)
ArrayList
d)
None of the above
43.
1. What should we use when add and remove operations are more frequent than get operations?
a)
LinkedList
b)
ArrayList
c)
Set
d)
None of the above
44.
Which of these packages contain all the collection classes?
a)
java.lang
b)
java.util
c)
java.net
d)
java.awt
45.

Which of the following classes extends HashMap and maintains the insertion order of the elements?

a)

TreeMap

b)

LinkedHashMap

c)

SortedMap

d)

None of the above

46.
Which one of the following interfaces implementation accepts only unique elements?
a)
Set
b)
Array
c)
List
d)
Map
47.

Which one of the following objects is used to store Key Value pair?

a)

List

b)

Set

c)

TreeMap

d)

SortedSet

48.

Which of the following methods is valid for HashMap class> Select all the correct methods.

a)

put

b)

add

c)

addAll

d)

get

49.

<c:out> is similar to ____________.

a)

<%! %>

b)

<%= %>

c)

<% %>

d)

None of the above.

50.

Which JSTL tag is used to iterate over a collection?

a)

<c:forEach>

b)

<c:if>

c)

<c:choose>

d)

<c:import>

51.

What is the purpose of the <c:forEach> tag in JSTL?

a)

To conditionally include content.

b)

To iterate over a collection of items.

c)

To format dates in a specific pattern.

d)

To define a custom tag library.

52.

In JSP, java code can be written inside the jsp page using _____________

a)

scriptlet tag

b)

expression tag

c)

declaration tag

d)

JSP include directive

53.

In JSP, java code can be written inside the jsp page using _____________

a)

scriptlet tag

b)

expression tag

c)

declaration tag

d)

JSP include directive

54.

JSPs eventually are compiled into Java servlets, you can do as much with JSPs as you can do with Java servlets.

a)

True

b)

False

55.

A JSP page consists of which tags?

a)

HTML tags

b)

JSP tags

c)

Both A & B

d)

None of the above

56.

In which file database table configuration is stored?

a)

.dbm

b)

.hbm

c)

.ora

d)

.sql

57.

What is bean in Spring?

a)

A component

b)

An Object

c)

A class

d)

A container

58.

What is the Annotation used for Rest controller

a)

@Restcontroller

b)

@Controller

c)

@RestController

d)

@SpringBootApplication

59.

What does API mean?

a)

Automated prediction interface

b)

Automated programming interface

c)

Application programming interface

d)

Application preparator innovated

60.

What is a web-service?

a)

A web service is a graphical user interface for accessing web pages.

b)

A web service is a software system that allows different applications to communicate and exchange data over the internet using standard protocols such as HTTP.

c)

A web service is a physical server that hosts websites and applications.

d)

A web service is a programming language used for building web applications.

61.

Which one out of the following is a JSON?

a)

[["name"],["Kare"]]

b)

{name: "Kare"}

c)

<name>Kare</name>

d)

{"name":"Kare"}

62.
What does the H in HTTP stand for?
a)
Hyper
b)
Hypertext
c)
HTML
d)
Helix
63.

What is the purpose of a REST API?

a)

To provide a simple URL for web services

b)

To support XML-based web service protocols

c)

To allow for the use of HTTP requests to GET, PUT, POST and DELETE data

d)

To only support mobile apps and websites

64.

Which HTTP request is used to retrieve data from a server in a REST API?

a)

PUT

b)

POST

c)

DELETE

d)

GET

65.

Which HTTP request is used to submit data to the server for a new resource in a REST API?

a)

GET

b)

POST

c)

PUT

d)

DELETE

66.

What architectural style and approach to communications is a RESTful API based on?

a)

SOAP

b)

WSDL

c)

Representational State Transfer technology

d)

XML

67.

Which HTTP request is used to delete a resource in a REST API?

a)

PUT

b)

POST

c)

DELETE

d)

GET

68.

Which of the following is an example of a path parameter in a RESTful API endpoint?

a)

?sort=ascending

b)

/users/{id}

c)

?query=searchterm

d)

/users?id=5

69.

What is the standard format for a RESTful API response?

a)

CSV

b)

XML

c)

JSON

d)

HTML

70.

What is Postman?

a)

A tool for creating and managing API documentation

b)

A tool for creating and testing API requests and responses

c)

A tool for monitoring and analyzing API performance

d)

A tool for visualizing API data

71.

Which embedded web server is supported by default in Spring Boot?

a)

Tomcat

b)

GlassFish

c)

WildFly

d)

Jetty

72.
What is default Web server used in Spring boot Application?
a)
Jetty
b)
Apache Tomcat
c)
JSP
73.

Which annotation in Spring Boot is used to map HTTP requests to handler methods?

a)

@RequestMapping

b)

@Entity

c)

@Controller

d)

@Configuration

74.

What is the default port number for a Spring Boot application?

a)

9090

b)

8080

c)

8000

d)

7070

75.

What is the annotation used to map a method parameter to a URI template variable?

a)

@PathVariable

b)

@Path

c)

@PathLocale

d)

None of the mentioned

76.

What is the correct annotation to declare a controller in Spring MVC?

a)

@Controller

b)

@ConfigController

c)

@SpringController

d)

@AppController

77.

Which of the following combinations are used to map a class to a database table?

a)

@Entity, @Table

b)

@Database, @Table

c)

@Database, @Entity, @Table

d)

@DB, @Table

78.

JVM stands for

a)

Java Vital Machine

b)

Java Virtual Machine

c)

Java Vendor machine

79.
When we want to print in Java, we use the code ......
a)
system.out.print();
b)
System.out.println();
c)
System.Out.Printf();
d)
System.out.show();
80.

JRE stands for

a)

Java Run Environment

b)

Java Run Execution

c)

Java Runtime Environment

d)

Java Ready Execution

81.

JDK stands for

a)

Java Developer Kit

b)

Java Development Kit

c)

Java Design Kit

d)

Java Debugging Kit

82.

Which of the following is assignment operator?

a)

==

b)

=

c)

=+

d)

++

83.

x /= 3


Which of the below statements matches with above statement?

a)

x = 3 / x

b)

x = x / 3

c)

x / 3

d)

x /x = 3

84.

int x = 4.4;

int y = 5.5;

System.out.println(x == y);


What will be the output?

a)

4.4

b)

true

c)

false

d)

5.5

85.

What is the output of below code?


int x = 5;

System.out.println(x++);

System.out.println(x);

a)

5

5

b)

6

6

c)

5

6

d)

6

5

86.

Which of these keywords is used to make a class?

a)

class

b)

struct

c)

int

d)

none of the mentioned

87.

What is the extension of compiled java classes?

a)

.java

b)

.class

c)

.txt

d)

.js

88.

Which of the below is invalid identifier with the main method?

a)

public

b)

static

c)

final

d)

private

89.

Which concept of Java is achieved by combining methods and attribute into a class?

a)

Encapsulation

b)

Inheritance

c)

Polymorphism

d)

Abstraction

90.

When does method overloading is determined?

a)

At run time

b)

At compile time

c)

At coding time

d)

At execution time

91.

Which of the following is a type of polymorphism in Java?

a)

Compile time polymorphism

b)

Execution time polymorphism

c)

Multiple polymorphism

d)

Multilevel polymorphism

92.

Which of these keywords is used to define interfaces in java

a)

intf

b)

Intf

c)

interface

d)

Interface

93.

Which of these keywords are used for the block to be examined for exceptions ?

a)

Check

b)

Throw

c)

Catch

d)

Try

94.

Which of these are selection statements in Java?

a)

if()

b)

for

c)

continue

d)

break

95.

Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?

a)

for

b)

while

c)

do..while

d)

None of the above

96.

Main() method is not mandatory for a Java program

a)

True

b)

False

97.

How do you handle exceptions in Java?

a)

By using try-catch blocks

b)

By ignoring the exceptions

c)

By using if-else statements

d)

By using switch-case statements

98.

What is inheritance in Java?

a)

Inheritance in Java is a process of creating a new class by extending an existing class.

b)

Inheritance in Java is a feature that allows a class to inherit properties from multiple classes.

c)

Inheritance in Java allows one class to inherit the properties and behaviors of another class.

d)

Inheritance in Java is used to create new classes from existing classes.

99.

What is the purpose of the 'final' keyword in Java?

a)

To allow the user to change the value of a variable

b)

To make a method optional

c)

To automatically initialize a variable

d)

To restrict the user from changing the value of a variable or to make a method unchangeable.

100.

Explain the difference between int and Integer in Java.

a)

int is used for whole numbers, while Integer is used for decimal numbers

b)

int is immutable, while Integer is mutable

c)

Integer is a class, while int is a primitive data type.

d)

int can be used for mathematical operations, while Integer cannot