0% found this document useful (0 votes)
3 views6 pages

Advance Java Questions With Answers 1749286738

The document is a comprehensive Q&A guide on advanced Java topics, covering JDBC, servlets, JSP, Hibernate, Spring Framework, and REST APIs. It includes key concepts, definitions, differences between related terms, and best practices for each topic. The content is structured in a question-and-answer format, making it a useful resource for learners and professionals in Java development.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views6 pages

Advance Java Questions With Answers 1749286738

The document is a comprehensive Q&A guide on advanced Java topics, covering JDBC, servlets, JSP, Hibernate, Spring Framework, and REST APIs. It includes key concepts, definitions, differences between related terms, and best practices for each topic. The content is structured in a question-and-answer format, making it a useful resource for learners and professionals in Java development.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

IMPORTANT ADVANCE JAVA Q&A

INSTRUCTOR: SHALINI RAVI

1. What is JDBC?

JDBC (Java Database Connectivity) is an API to connect and execute queries with

a database.

2. What are the main steps in JDBC?

Load driver, establish connection, create statement, execute query, close

connection.

3. What are different JDBC drivers?

JDBC-ODBC Bridge, Native-API, Network Protocol, Thin Driver.

4. Difference between Statement and PreparedStatement?

Statement is static, PreparedStatement is precompiled and supports dynamic

queries with parameters.

5. What is ResultSet in JDBC?

ResultSet is a table of data representing results from a SQL query.

6. How do you prevent SQL Injection in JDBC?

Use PreparedStatement or CallableStatement.

7. What is the use of CallableStatement?

Used to execute stored procedures in the database.


1
8. What is connection pooling?

Reusing database connections instead of creating a new one for each request.

9. What is a servlet?

A servlet is a Java class used to handle HTTP requests and responses in a web

application.

10. Servlet life cycle?

init(), service(), destroy()

11. Difference between GET and POST?

GET appends data to URL and is less secure; POST sends data in the body and is

more secure.

12. What is the web.xml file?

Deployment descriptor for a Java web application, used to configure servlets and

filters.

13. How do you redirect in servlets?

response.sendRedirect("url");

14. How to forward a request in servlet?

RequestDispatcher.forward(request, response);

15. Difference between forward() and sendRedirect()?

forward stays on server, sendRedirect changes URL and makes new request.

16. What is a filter in servlet?

Filter intercepts requests and responses to apply preprocessing or postprocessing.

2
17. What is a session in Java web app?

A session stores user-specific data during a user interaction with a web app.

18. How to manage session in servlets?

Using HttpSession object.

19. What is a cookie?

A small piece of data stored on the client to maintain session state.

20. Difference between session and cookie?

Session is server-side, cookie is client-side.

21. What is JSP?

JSP (JavaServer Pages) is a technology for developing web pages with dynamic

content using Java.

22. Difference between JSP and Servlet?

JSP is for presentation; Servlets are for processing logic.

23. What are JSP directives?

Instructions to the JSP container, like <%@ page %>, <%@ include %>, <%@

taglib %>.

24. What is scriptlet in JSP?

Java code enclosed within <% %> tags.

25. What is JSP expression?

<%= expression %> used to output result directly on web page.

26. What is JSTL?

JSP Standard Tag Library – simplifies JSP code using tags instead of scriptlets.

3
27. What is MVC architecture in Java web?

Model-View-Controller separates concerns: Model = logic, View = UI, Controller

= flow.

28. What is Hibernate?

An ORM (Object-Relational Mapping) framework to map Java objects to database

tables.

29. What are advantages of Hibernate?

Reduces boilerplate JDBC code, supports caching, database-independent.

30. What is HQL?

Hibernate Query Language, similar to SQL but works with entity names and

properties.

31. Difference between save() and persist() in Hibernate?

save() returns identifier, persist() doesn't; persist is JPA-compliant.

32. What is lazy loading in Hibernate?

Objects are loaded only when needed.

33. What is cascade in Hibernate?

Automatically performs operations like persist, delete on associated entities.

34. What are the states of an object in Hibernate?

Transient, Persistent, Detached.

35. What is Spring Framework?

A lightweight Java framework for building enterprise applications using

dependency injection.

4
36. What is dependency injection?

Process of supplying dependencies from outside instead of creating inside the

class.

37. Difference between constructor and setter injection?

Constructor injects through constructor, setter injects via setter methods.

38. What is Spring Bean?

An object managed by the Spring IoC container.

39. What is Spring Boot?

Spring Boot simplifies Spring app development with auto-configuration and

embedded servers.

40. What is @RestController in Spring?

Combines @Controller and @ResponseBody to create RESTful web services.

41. Difference between @Component, @Service, @Repository?

All are stereotypes for beans; Service is for business logic, Repository for

database, Component for generic.

42. What is REST API?

An architectural style for building web services using HTTP methods like GET,

POST, PUT, DELETE.

43. Difference between REST and SOAP?

REST is lightweight and uses HTTP; SOAP is XML-based and heavier.

5
44. What is JSON and why is it used in REST?

JSON (JavaScript Object Notation) is a lightweight data-interchange format, used

for data exchange in REST APIs.

45. How to consume REST API in Java?

Using libraries like HttpURLConnection, Apache HttpClient, or RestTemplate

(Spring).

46. What is a DAO?

Data Access Object – a pattern to separate persistence logic from business logic.

47. What is the difference between DTO and Entity?

DTO carries data between layers, Entity represents DB table.

48. What is transaction management in Spring?

Handling commit/rollback behavior using @Transactional annotation.

49. How do you handle exceptions in Spring REST API?

Using @ControllerAdvice and @ExceptionHandler.

50. What is Swagger in Spring Boot?

A tool for documenting and testing REST APIs with a user-friendly UI.

You might also like