0% found this document useful (0 votes)
6 views4 pages

Advanced_Java_Viva_Questions_With_Answers_Clean

The document contains advanced Java programming viva questions for diploma students, covering core concepts such as servlets, JSP, JDBC, networking, multithreading, JavaBeans, and MVC architecture. It includes explanations of key terms, differences between concepts, and practical coding examples. The content is structured in a question-and-answer format to aid in understanding and preparation for exams.

Uploaded by

pranavgayki123
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)
6 views4 pages

Advanced_Java_Viva_Questions_With_Answers_Clean

The document contains advanced Java programming viva questions for diploma students, covering core concepts such as servlets, JSP, JDBC, networking, multithreading, JavaBeans, and MVC architecture. It includes explanations of key terms, differences between concepts, and practical coding examples. The content is structured in a question-and-answer format to aid in understanding and preparation for exams.

Uploaded by

pranavgayki123
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/ 4

Advanced Java Programming - Viva Questions (Diploma 3rd Year)

Core Concepts

Q: What is the difference between Core Java and Advanced Java?

A: Core Java is used for general-purpose programming, whereas Advanced Java is used for web-based

applications and enterprise-level development.

Q: What is a Servlet? How does it work?

A: A servlet is a Java class that handles HTTP requests and responses in a web application. It runs on a

server and generates dynamic web content.

Q: What is the lifecycle of a Servlet?

A: 1. init() - initializes the servlet

2. service() - processes requests

3. destroy() - called before servlet is removed.

Q: What is the difference between GET and POST methods?

A: GET sends data via URL and is less secure, while POST sends data in the request body and is more

secure for sensitive data.

Q: What is a JSP (JavaServer Page)? How is it different from a servlet?

A: JSP is an HTML page with Java code embedded, while servlet is a Java program. JSP is easier for

creating UI.

Q: What are implicit objects in JSP?

A: They are pre-defined objects like request, response, session, application, out, config, pageContext, etc.

Q: What is the difference between forward() and sendRedirect()?

A: forward() transfers control within the server; sendRedirect() sends a new request from the client browser.

Q: What is a Session? How is it maintained?

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)

Q: What is the difference between Session, Cookie, and Application Context?

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.

Q: Explain the steps to connect Java with MySQL using JDBC.

A: 1. Load the driver

2. Establish connection

3. Create statement

4. Execute query

5. Close connection

Q: What are drivers in JDBC?

A: Drivers are software components that enable Java to communicate with databases.

Q: What is the difference between Statement and PreparedStatement?

A: PreparedStatement is precompiled and safer from SQL injection, whereas Statement is compiled every

time.

Q: What are the types of JDBC drivers?

A: 1. JDBC-ODBC bridge

2. Native-API

3. Network Protocol

4. Thin driver (pure Java)

Q: What is ResultSet?

A: It is an object that holds the result of a query executed using JDBC.


Advanced Java Programming - Viva Questions (Diploma 3rd Year)

Networking

Q: What is socket programming?

A: It is a way to connect two machines over a network using TCP or UDP for communication.

Q: What is the difference between TCP and UDP in Java networking?

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

Q: What is a Thread? How do you create a thread in Java?

A: A thread is a lightweight subprocess. Create using Thread class or implementing Runnable interface.

Q: What is the difference between Runnable and Thread class?

A: Runnable allows extending other classes; Thread doesn't. Runnable is preferred in large applications.

JavaBeans & MVC

Q: What is a JavaBean?

A: A JavaBean is a reusable software component with getter/setter methods, no-arg constructor, and

serializable.

Q: What is the MVC architecture in Java?

A: MVC (Model-View-Controller) separates application into Model (data), View (UI), Controller (logic).

Q: What are the components of MVC?

A: Model - handles data

View - displays UI

Controller - manages interaction between Model and View


Advanced Java Programming - Viva Questions (Diploma 3rd Year)

Practical / Coding-based

Q: Write code to connect to a MySQL database and fetch records.

A: Connection con = DriverManager.getConnection("jdbc:mysql://localhost/db","user","pass");

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery("SELECT * FROM table");

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.

Q: Write a JSP program to take user input and display it.

A: <form method='post'>

<input name='user'/>

<input type='submit'/>

</form>

<%= request.getParameter("user") %>

Q: Write a program to implement simple login using session tracking.

A: Store username in session: session.setAttribute("user", name);

Retrieve: session.getAttribute("user");

You might also like