Font size
WorksheetsJava Full Stack Test 24-03-2025
Total questions: 100
Worksheet time: 1hrs 15mins
where can you keep .java files in webapplication(Servlets)?
root directory
WEB-INF
src
classes
The _______ specification defines an application programming interface for communication between the server and the application program
Java Servlet
java jdbc
java applet
java swing
Which packages represent interfaces and classes for servlet API?
javax.servlet
javax.servlet.http
both 1 and 2
none of the above
What is the lifecycle of a servlet?
Servlet class is loaded
Servlet instance is created
init(),service() and destroy() methods will be called
All the above
How many times init() method is called during life time of a servlet?
two times
one time
several times
never called
How many time destroy() method will be called during the life time of a Servlet?
one
two
several time
never called
When will call init() method of a servlet?
(a)
When destroy method() of servlet called ?
for first request
when you close the browser window
when you remove the application from server
none of the above
web.xml file is available in which directory of web application.
root directory
WEB-INF directory
src
classes
where can you keep .java files in webapplication(Servlets)?
root directory
WEB-INF
src
classes
All html pages will be placed in ----------- directory
root directory
WEB-INF
src
classes
web.xml is also called as --------------------
data directory
deployment descriptor
directroy descriptor
none of the above
what is root tag of web.xml ?
web-app
servlet
servlet-mapping
init-param
under which tag of web.xml file contains actual servlet class
web-app
init-param
servlet
servlet-mapping
Where to place user defined webapplications in webserver (Apache Tomcat)
in bin directory
in lib directory
webapps directory
work directory
In which jar file contains the entire servlet API
servlet-api.jar
catalina.jar
tomcat-api.jar
jasper.jar
What are the methods of ServletConfig Interface?
getInitParameter()
getServletName()
getServletContext()
all the above
What are the parameters of the service() method
ServletConfig,ServletContext
doGet,doPost
init-param
ServletRequest,ServletResponse
What is the parent tag of url-pattern tag in web.xml?
servlet tag
webapp tag
servlet-mapping tag
none of the above
What are the methods of RequestDispatcher Interface?
doGet(),doPost()
include(),forward()
backward(),doHead()
doLink(),return
How many types of cookies are available in servlets?
2
4
8
6
doGet(),doPost() methods are available in which class ?
GenericServlet
HttpServlet
Both 1 & 2
None of the above
How many Ways to we create Sessions?
2
6
8
4
What are the different Exceptions thrown by service() method?
(a)
What are the different types of Cookies?
writecookie, tempcookies
strongcookie,weekcookies
persistent,non-persistent
none of the above
JSP stands for __________.
Java Server Page
Java Second Page
Java Service Page
Java Spring Page
Which method is used to register a jdbc driver?
Class.ForName()
Class.forName()
class.ForName()
class.forName()
Java Server Pages (JSP) is a ------------------------------
client-side programming technology
server-side programming technology
Both
Which of the following is syntax of Expression Tag?
<% Expression %>
<%= Expression %>
<& Expression &>
<%! Expression %>
4. In the below statement, which type of query can be used with executeUpdate( ) method. statement.executeUpdate (query here)?
Insert, Update, Delete
Insert, Select, Delete
Only Select
Any Query
Which method of HttpServletRequest is used to read the value of HTML form elements
getValue()
getInputText()
getParameter()
getAttributes()
which of the following are methods of user request handling in servlet
doGet()
doPost()
Both of them
None of these
•Servlet is an ---------------- that must be implemented for creating any Servlet.
interface
class
method
variable
Which of these interface declares core method that all collections will have?
Collection
EventListner
Comparator
Set
List
What is the purpose of the List interface in Java?
To store and maintain an ordered collection
To provide index-based methods for manipulating elements
To accommodate duplicate elements and store null elements
To iterate the list in both forwards and backwards directions
Which of the following is an implementation class of the List interface?
ArrayList
StringList
Stack
Vector
Which of the following is an implementation class of the Set interface?
HashSet
LinkedHashSet
ArrayList
LinkedList
What is the main difference between List and Set interfaces?
List is an ordered sequence, while Set is an unordered sequence
List allows the inclusion of duplicate elements, while Set does not
List allows position access to elements, while Set does not
List can store multiple null elements, while Set can only store one
What is Collection in Java?
A group of objects
A group of classes
A group of interfaces
None of the mentioned
Which of the following classes extends HashMap and maintains the insertion order of the elements?
TreeMap
LinkedHashMap
SortedMap
None of the above
Which one of the following objects is used to store Key Value pair?
List
Set
TreeMap
SortedSet
Which of the following methods is valid for HashMap class> Select all the correct methods.
put
add
addAll
get
<c:out> is similar to ____________.
<%! %>
<%= %>
<% %>
None of the above.
Which JSTL tag is used to iterate over a collection?
<c:forEach>
<c:if>
<c:choose>
<c:import>
What is the purpose of the <c:forEach> tag in JSTL?
To conditionally include content.
To iterate over a collection of items.
To format dates in a specific pattern.
To define a custom tag library.
In JSP, java code can be written inside the jsp page using _____________
scriptlet tag
expression tag
declaration tag
JSP include directive
In JSP, java code can be written inside the jsp page using _____________
scriptlet tag
expression tag
declaration tag
JSP include directive
JSPs eventually are compiled into Java servlets, you can do as much with JSPs as you can do with Java servlets.
True
False
A JSP page consists of which tags?
HTML tags
JSP tags
Both A & B
None of the above
In which file database table configuration is stored?
.dbm
.hbm
.ora
.sql
What is bean in Spring?
A component
An Object
A class
A container
What is the Annotation used for Rest controller
@Restcontroller
@Controller
@RestController
@SpringBootApplication
What does API mean?
Automated prediction interface
Automated programming interface
Application programming interface
Application preparator innovated
What is a web-service?
A web service is a graphical user interface for accessing web pages.
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.
A web service is a physical server that hosts websites and applications.
A web service is a programming language used for building web applications.
Which one out of the following is a JSON?
[["name"],["Kare"]]
{name: "Kare"}
<name>Kare</name>
{"name":"Kare"}
What is the purpose of a REST API?
To provide a simple URL for web services
To support XML-based web service protocols
To allow for the use of HTTP requests to GET, PUT, POST and DELETE data
To only support mobile apps and websites
Which HTTP request is used to retrieve data from a server in a REST API?
PUT
POST
DELETE
GET
Which HTTP request is used to submit data to the server for a new resource in a REST API?
GET
POST
PUT
DELETE
What architectural style and approach to communications is a RESTful API based on?
SOAP
WSDL
Representational State Transfer technology
XML
Which HTTP request is used to delete a resource in a REST API?
PUT
POST
DELETE
GET
Which of the following is an example of a path parameter in a RESTful API endpoint?
?sort=ascending
/users/{id}
?query=searchterm
/users?id=5
What is the standard format for a RESTful API response?
CSV
XML
JSON
HTML
What is Postman?
A tool for creating and managing API documentation
A tool for creating and testing API requests and responses
A tool for monitoring and analyzing API performance
A tool for visualizing API data
Which embedded web server is supported by default in Spring Boot?
Tomcat
GlassFish
WildFly
Jetty
Which annotation in Spring Boot is used to map HTTP requests to handler methods?
@RequestMapping
@Entity
@Controller
@Configuration
What is the default port number for a Spring Boot application?
9090
8080
8000
7070
What is the annotation used to map a method parameter to a URI template variable?
@PathVariable
@Path
@PathLocale
None of the mentioned
What is the correct annotation to declare a controller in Spring MVC?
@Controller
@ConfigController
@SpringController
@AppController
Which of the following combinations are used to map a class to a database table?
@Entity, @Table
@Database, @Table
@Database, @Entity, @Table
@DB, @Table
JVM stands for
Java Vital Machine
Java Virtual Machine
Java Vendor machine
JRE stands for
Java Run Environment
Java Run Execution
Java Runtime Environment
Java Ready Execution
JDK stands for
Java Developer Kit
Java Development Kit
Java Design Kit
Java Debugging Kit
Which of the following is assignment operator?
==
=
=+
++
x /= 3
Which of the below statements matches with above statement?
x = 3 / x
x = x / 3
x / 3
x /x = 3
int x = 4.4;
int y = 5.5;
System.out.println(x == y);
What will be the output?
4.4
true
false
5.5
What is the output of below code?
int x = 5;
System.out.println(x++);
System.out.println(x);
5
5
6
6
5
6
6
5
Which of these keywords is used to make a class?
class
struct
int
none of the mentioned
What is the extension of compiled java classes?
.java
.class
.txt
.js
Which of the below is invalid identifier with the main method?
public
static
final
private
Which concept of Java is achieved by combining methods and attribute into a class?
Encapsulation
Inheritance
Polymorphism
Abstraction
When does method overloading is determined?
At run time
At compile time
At coding time
At execution time
Which of the following is a type of polymorphism in Java?
Compile time polymorphism
Execution time polymorphism
Multiple polymorphism
Multilevel polymorphism
Which of these keywords is used to define interfaces in java
intf
Intf
interface
Interface
Which of these keywords are used for the block to be examined for exceptions ?
Check
Throw
Catch
Try
Which of these are selection statements in Java?
if()
for
continue
break
Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?
for
while
do..while
None of the above
Main() method is not mandatory for a Java program
True
False
How do you handle exceptions in Java?
By using try-catch blocks
By ignoring the exceptions
By using if-else statements
By using switch-case statements
What is inheritance in Java?
Inheritance in Java is a process of creating a new class by extending an existing class.
Inheritance in Java is a feature that allows a class to inherit properties from multiple classes.
Inheritance in Java allows one class to inherit the properties and behaviors of another class.
Inheritance in Java is used to create new classes from existing classes.
What is the purpose of the 'final' keyword in Java?
To allow the user to change the value of a variable
To make a method optional
To automatically initialize a variable
To restrict the user from changing the value of a variable or to make a method unchangeable.
Explain the difference between int and Integer in Java.
int is used for whole numbers, while Integer is used for decimal numbers
int is immutable, while Integer is mutable
Integer is a class, while int is a primitive data type.
int can be used for mathematical operations, while Integer cannot
