Answers Converted into 2-3 Lines
Image 1 Answers
a) What is use of CallableStatement?
CallableStatement is used in JDBC to execute stored procedures. It extends PreparedStatement and is created via
prepareCall().
b) What is thread?
A thread is the smallest unit of execution, allowing concurrent operations. In Java, threads are created using the Thread
class or implementing Runnable.
c) How servlet differs from CGI?
Servlets run inside a container handling HTTP requests efficiently, while CGI scripts are standalone processes. Servlets
offer better performance and platform independence.
d) Define Set.
A Set is a collection that holds unique elements without duplicates. Examples include HashSet, TreeSet, and
LinkedHashSet.
e) List any two parameters using scriptlet.
Scriptlets embed Java in JSP. For example, retrieving parameters:
String username = request.getParameter("username");
String userAgent = request.getHeader("User-Agent");
Image 2 Answers
f) Define spring.
Spring is a lightweight, open-source Java framework for building scalable applications. It includes modules like Spring
MVC and Spring AOP.
g) Which interface is implemented by TreeSet class?
TreeSet implements the SortedSet interface, maintaining elements in a sorted order.
h) List any two methods of Statement interface.
1. executeQuery(String sql) for SELECT queries returning a ResultSet.
2. executeUpdate(String sql) for executing DML/DDL commands and updating rows.
i) Write the purpose of yield().
The yield() method lets the current thread pause to allow other threads to run. It improves thread scheduling and CPU
resource distribution.
j) What is cookie?
A cookie is a small text file stored in a browser by a web server. It holds user-specific data for session tracking.
Image 3 Answers
a) What is collection?
A collection is an object grouping multiple elements, providing data storage and manipulation using lists, sets, queues,
or maps.
b) Define Thread Priority.
Thread priority determines the order of execution when multiple threads compete for CPU time; values range from 1
(lowest) to 10 (highest).
c) What is JDBC?
JDBC (Java Database Connectivity) is an API that connects Java applications to databases. It uses classes like
Connection, Statement, and ResultSet.
d) Define session.
A session stores user data across multiple requests with a unique session ID, usually held in cookies or URL
parameters.
e) What is use of request object?
The HttpServletRequest object holds client request data (parameters, headers). It's used in servlets to process and
respond to client inputs.
f) Write any one application of spring.
Spring supports enterprise app development. For instance, Spring MVC enables building robust web applications using
the Model-View-Controller architecture.
g) What is use of join() method?
The join() method makes one thread wait for the completion of another, ensuring sequential execution where necessary.
Image 4 Answers
h) Define Hashtable.
Hashtable is a synchronized collection that stores key-value pairs. It is thread-safe but does not allow null keys or
values.
i) What is use of commit() method?
The commit() method finalizes a database transaction by permanently saving changes. It is used to confirm successful
operations in a transaction.
j) List any two implicit objects in JSP.
- request: Represents the client's HTTP request for accessing parameters and headers.
- response: Used to generate and send HTTP response content to the client.
Image 5 Answers
1. What is Map?
A Map stores key-value pairs with unique keys mapping to single values. It is part of the Collections Framework,
including implementations like HashMap and TreeMap.
2. What is use of wait() and thread interrupt()?
wait() causes a thread to pause and release its lock until notified. interrupt() signals a thread to stop waiting or sleeping.
3. How to get Connection()?
Use DriverManager.getConnection(url, username, password) to establish a connection to the database, which returns a
Connection object.
4. What is Expression Language (EL)?
EL simplifies accessing Java objects and properties in JSP pages using a concise syntax like ${user.name}.
5. Give an example of directive tag.
Example:
<%@ page import="java.util.*" %>
6. What is difference between Set and List?
A Set holds unique elements without duplicates, whereas a List can contain duplicates and maintains insertion order.
7. What is Link Tag?
In JSP, the <link> tag is typically an HTML element used to import external resources (e.g., CSS). It is standard HTML
and not a special JSP tag.
Image 6 Answers
1. What is the purpose of JSP directives?
JSP directives (<%@ ... %>) instruct the JSP container on how to process the page. Examples include the page,
include, and taglib directives.
2. Define Spring Framework.
Spring is an open-source Java framework that manages dependencies with Inversion of Control (IoC). It includes
modules for web development (Spring MVC), AOP, and more.
3. Setup steps to develop a servlet.
Develop a servlet by extending HttpServlet and overriding doGet()/doPost(). Configure it in web.xml or via annotations,
compile, and deploy in a servlet container.
4. What are the types of JDBC API?
There are four JDBC driver types: Type 1 (JDBC-ODBC bridge), Type 2 (native API), Type 3 (middleware), and Type 4
(pure Java). Type 4 drivers are most commonly used.