Q2 – 2 Mark Answers
1. Describe JDBC.
JDBC (Java Database Connectivity) is a Java API used to connect and execute queries with relational
databases. It provides standard interfaces for sending SQL statements, retrieving results, and managing
transactions in a platform-independent way.
2. What is MVC?
MVC (Model–View–Controller) is a software architecture pattern that separates an application into Model
(data), View (UI), and Controller (logic). This separation improves maintainability, scalability, and clarity.
3. What is Struts?
Struts is an MVC-based Java web framework that uses Action classes, XML configuration, and tag libraries
to simplify web application development. It centralizes request handling through ActionServlet.
4. Name the four types of JDBC drivers.
JDBC-ODBC Bridge Driver, Native API Driver, Network Protocol Driver, and Thin (Pure Java) Driver.
5. What is JDBC Drivers?
JDBC drivers are software components that translate Java JDBC calls into database-specific
communication. They enable Java programs to communicate with di erent relational databases.
6. What are the Features of MVC?
Separation of concerns, modular structure, easier testing, improved maintainability, and the ability to
update UI and logic independently.
7. List any two JDBC interfaces and explain their role briefly.
Connection: establishes a link with the database.
Statement: executes SQL queries and retrieves results.
8. List the Components of Struts.
ActionServlet, ActionForm, Action classes, struts-confi[Link], JSP views, and tag libraries.
9. Define Hibernate.
Hibernate is an ORM framework that maps Java objects to database tables. It automates CRUD
operations and reduces manual SQL.
10. What is the use of Hibernate Dialect?
Hibernate Dialect tells Hibernate how to generate SQL for a specific database by defining functions, data
types, and syntax rules.
11. Define Spring Framework.
Spring is a lightweight Java framework o ering dependency injection, modular architecture, and
integration support for enterprise applications.
12. What is ORM in Hibernate?
ORM (Object-Relational Mapping) maps Java classes to database tables, enabling data manipulation
through objects instead of SQL commands.
13. What is dependency injection?
Dependency Injection provides required objects to a class from an external source instead of creating
them internally, reducing coupling and improving testability.
14. What is the role of the IOC Container in Spring?
The IoC container creates, manages, and injects dependencies into Spring beans. It controls object
lifecycle and wiring using configuration.
15. Define Constructor Injection.
Constructor Injection provides dependencies through the class constructor, ensuring mandatory
dependencies are set at object creation time.
16. Explain any two key components of Hibernate architecture.
SessionFactory: creates sessions and manages connection settings.
Session: performs CRUD operations and manages persistence context.
17. What are the Spring Framework Modules?
Core Container, AOP, Data Access/ORM, Web MVC, Test, Messaging, and Integration modules.
──────────────────────────────────────────────
Q3 – 4 Mark Answers
1. Explain the classes or interfaces used in JDBC for creating a database application.
JDBC uses several core interfaces such as Driver, Connection, Statement, PreparedStatement,
CallableStatement, ResultSet, and ResultSetMetaData. The Driver interface loads the driver, while
Connection establishes database links. Statement and PreparedStatement execute SQL queries, whereas
CallableStatement handles stored procedures. ResultSet retrieves row data, and metadata interfaces
provide information about tables and columns. These components together enable complete database
operations within a Java program.
2. Explain how form data is validated using Struts Validator.
Struts Validator uses the validation framework defined in [Link] and [Link].
Developers specify validation rules for fields such as required, email, minLength, and mask patterns. At
runtime, the ValidatorForm or DynaValidatorForm automatically checks form data before calling the
Action class. If errors occur, they are stored in ActionErrors and displayed using Struts tags. This approach
reduces coding e ort and enforces centralized validation.
3. Explain the components of JDBC.
JDBC consists of Drivers, DriverManager, Connection, Statement, and ResultSet. Drivers enable
communication with databases, while DriverManager selects appropriate drivers based on URLs.
Connection represents a session with the database and manages transactions. Statement and
PreparedStatement execute SQL commands, and ResultSet retrieves query results row by row. These
components work together to provide complete data connectivity for Java applications.
4. What is Struts? Explain the versions of Struts.
Struts is a Java MVC framework used for building structured web applications. Struts 1 is based on
ActionForms, centralized ActionServlet, and XML configuration. Struts 2 is redesigned with better
flexibility, OGNL support, interceptors, and annotation-based configuration. Struts 2 integrates WebWork
features, improves performance, and removes ActionForm limitations, making development faster and
cleaner.
5. Explain Prepared Statement with example.
PreparedStatement is a precompiled SQL statement used to execute parameterized queries. It improves
performance and prevents SQL injection. Example:
PreparedStatement ps = [Link]("INSERT INTO emp VALUES (?, ?)");
[Link](1, 101);
[Link](2, "Raj");
[Link]();
Since the SQL is compiled once, repeated execution becomes faster and more secure.
6. What is Inheritance Mapping? Explain the Table per Hierarchy strategy.
Inheritance mapping maps Java class inheritance to relational tables. Table per Hierarchy stores all
subclass attributes in a single table with a discriminator column. This reduces joins and improves
performance but may create sparse tables with many null fields. It is the simplest and most commonly
used strategy in Hibernate.
7. Explain the features of Spring Framework.
Spring provides lightweight containers, dependency injection, modular architecture, aspect-oriented
programming, transaction management, and integration with ORM tools. It simplifies enterprise Java
development, promotes loose coupling, and supports declarative configurations using XML and
annotations. Its powerful modules allow easy creation of scalable, testable applications.
8. What is Dialect? Write a list of SQL Dialects in Hibernate.
Hibernate Dialect defines SQL syntax for specific databases, enabling Hibernate to generate optimized
SQL. Common dialects include MySQLDialect, OracleDialect, PostgreSQLDialect, SQLServerDialect,
H2Dialect, and DB2Dialect. Each dialect supports vendor-specific functions and datatypes.
9. Define IOC and explain types of IOC container.
IoC (Inversion of Control) shifts object creation and dependency management from code to a container.
Spring provides two IoC containers: BeanFactory and ApplicationContext. BeanFactory provides basic DI
features and lazy loading, while ApplicationContext adds advanced features like event handling,
internationalization, and eager loading. Both containers manage bean life cycles and dependencies.
──────────────────────────────────────────────
Q4 – 4 Mark Answers
1. Describe the architecture of JDBC in detail.
JDBC architecture includes the Java application layer, JDBC API, DriverManager, JDBC drivers, and the
database. The application calls JDBC APIs such as Connection and Statement, which communicate with
DriverManager. DriverManager selects the appropriate driver to establish the connection. The driver
converts JDBC calls into database-specific instructions. The database processes queries and returns
results through ResultSet. This layered architecture ensures platform-independent data access.
2. Explain the role of Model, View and Controller in MVC.
The Model stores data and business logic, updating data structures and interacting with the database. The
View displays data to the user and gets updated when the Model changes. The Controller handles user
requests, interacts with the Model, and selects appropriate Views. This separation enhances clarity,
testing, and maintenance while avoiding code duplication.
3. Discuss the Network Protocol Driver in detail with advantages and disadvantages.
The Network Protocol Driver (Type 3) uses a middleware server to translate JDBC calls into database-
specific protocols. It is platform-independent and supports multiple databases through one driver.
Advantages include flexibility, remote access, and centralized database connectivity. Disadvantages
include dependency on middleware, slower performance, and maintenance overhead. It suits large
enterprise systems requiring distributed access.
4. What are Drivers? Explain Native-API Driver in detail with advantages and disadvantages.
Drivers translate JDBC calls into database commands. The Native API Driver (Type 2) uses native client
libraries to communicate with the database. It o ers better performance than Type 1 and supports
vendor-specific features. However, it requires native library installation, is not portable, and is di icult to
maintain across OS platforms, limiting its enterprise use.
5. What are Hibernate Generator classes? Give examples.
Hibernate generator classes automatically generate primary key values for entities. They include identity,
sequence, increment, uuid, and assigned strategies. For example, @GeneratedValue(strategy =
[Link]) uses database auto-increment, while UUID generates unique identifiers
programmatically. These strategies simplify key management and ensure consistent identity handling.
6. Explain features of Spring Framework.
Spring provides lightweight containers, dependency injection, aspect-oriented programming, transaction
management, and modular architecture. It supports declarative configuration, integration with
Hibernate/JPA, and MVC for web applications. Its IoC container allows automatic wiring of objects,
improving modularity and testability. Spring simplifies large enterprise application development.
7. What is annotations? Explain various annotations in Hibernate.
Annotations are metadata added to Java code to define mapping information. Hibernate provides
annotations like @Entity (marks class as table), @Table (specifies table name), @Id (defines primary key),
@GeneratedValue (key generation strategy), @Column (maps fields to columns), and
@OneToMany/@ManyToOne for relationships. These annotations remove the need for XML configuration.
8. Explain the concept of Dependency Injection in Spring.
Dependency Injection provides required objects to classes instead of creating them manually. Spring
supports Constructor Injection, Setter Injection, and Field Injection. The IoC container handles wiring
using XML or annotations such as @Autowired. DI reduces coupling, increases reusability, and simplifies
testing by allowing mock replacements.
──────────────────────────────────────────────
Q5 – 8 Mark Answers
1. Explain the Components of Struts in detail.
Struts consists of several key components forming the MVC architecture. The ActionServlet acts as the
controller, receiving requests and routing them. ActionForm or POJOs collect and validate user input.
Action classes contain business logic and interact with the model. The struts-confi[Link] file maps
requests, actions, and views. JSP pages serve as the View using Struts tag libraries for dynamic data. The
RequestProcessor handles the flow between controller and actions. Validators manage field-level
validation through XML files. Together, these components implement a structured and maintainable web
application.
2. Discuss any two types of JDBC drivers in detail with advantages and disadvantages.
Type 2 (Native API Driver) uses native client libraries and provides high performance with database-
specific features. It has disadvantages such as platform dependency and complex setup.
Type 4 (Thin Driver) is a pure Java driver communicating directly with the database. It is portable, easy to
deploy, and fast. However, each database requires a separate driver, and advanced features may vary.
Both drivers are widely used depending on enterprise needs.
3. Explain the Built-in Validators in Struts.
Struts Validator Framework provides built-in rules such as required, minLength, maxLength, email, date,
mask, and numeric. These validators are defined in [Link] and applied to form fields through
[Link]. During form submission, the framework checks rules automatically and stores errors in
ActionErrors. JSP pages display messages using <html:errors>. This approach eliminates manual
validation coding, enhances consistency, and speeds up development. It also supports custom validators
for complex requirements.
4. What is Hibernate? Explain the features of Hibernate.
Hibernate is an ORM tool that maps Java objects to relational database tables. It automates SQL
operations, manages object states, and provides caching and transaction management. Features include
transparent persistence, lazy loading, HQL query language, automatic table generation, and support for
multiple databases. Hibernate reduces boilerplate JDBC code, improves productivity, and simplifies
complex relational mappings through annotations or XML configurations.
5. Explain in detail architecture of Hibernate.
Hibernate architecture includes Configuration, SessionFactory, Session, Transaction, Query, and Mapping
files. Configuration loads properties and mapping metadata. SessionFactory is a heavyweight object
creating multiple Sessions. Session represents a single unit of work and manages persistent objects.
Transaction ensures atomic operations and rollback support. Query (HQL/Criteria) retrieves and
manipulates data. Mapping files or annotations define relationships between Java classes and tables. The
database processes SQL generated by Hibernate. This layered architecture ensures clean separation,
portability, and e icient data access.