Advanced_Java_Viva_Questions_With_Answers_Clean
Advanced_Java_Viva_Questions_With_Answers_Clean
Core Concepts
A: Core Java is used for general-purpose programming, whereas Advanced Java is used for web-based
A: A servlet is a Java class that handles HTTP requests and responses in a web application. It runs on a
A: GET sends data via URL and is less secure, while POST sends data in the request body and is more
A: JSP is an HTML page with Java code embedded, while servlet is a Java program. JSP is easier for
creating UI.
A: They are pre-defined objects like request, response, session, application, out, config, pageContext, etc.
A: forward() transfers control within the server; sendRedirect() sends a new request from the client browser.
A: A session stores user data across multiple requests. It is maintained using cookies or URL rewriting.
Advanced Java Programming - Viva Questions (Diploma 3rd Year)
A: Session is user-specific, cookie is stored on the client, application context is shared across the whole
application.
Database (JDBC)
Q: What is JDBC?
A: Java Database Connectivity (JDBC) is an API that allows Java to connect and interact with databases.
2. Establish connection
3. Create statement
4. Execute query
5. Close connection
A: Drivers are software components that enable Java to communicate with databases.
A: PreparedStatement is precompiled and safer from SQL injection, whereas Statement is compiled every
time.
A: 1. JDBC-ODBC bridge
2. Native-API
3. Network Protocol
Q: What is ResultSet?
Networking
A: It is a way to connect two machines over a network using TCP or UDP for communication.
A: TCP is connection-oriented and reliable, UDP is connectionless and faster but unreliable.
Q: What is a ServerSocket?
A: ServerSocket is used by the server to listen for client requests on a specific port.
Multithreading
A: A thread is a lightweight subprocess. Create using Thread class or implementing Runnable interface.
A: Runnable allows extending other classes; Thread doesn't. Runnable is preferred in large applications.
Q: What is a JavaBean?
A: A JavaBean is a reusable software component with getter/setter methods, no-arg constructor, and
serializable.
A: MVC (Model-View-Controller) separates application into Model (data), View (UI), Controller (logic).
View - displays UI
Practical / Coding-based
Q: Write a servlet that accepts a user name and password and displays them on another page.
A: Use doPost() to get parameters using request.getParameter("name") and forward to a JSP page.
A: <form method='post'>
<input name='user'/>
<input type='submit'/>
</form>
Retrieve: session.getAttribute("user");