### ✅ **Repeated 2-Marks Questions (Total: 11)**
| Question | Times | Years
|
| ------------------------------------------------- | ----- |
-------------------------------------- |
| What is Java Bean? | 4 | May 2021, Dec 2021,
May 2023, Dec 2023 |
| What are the types of EJB? | 3 | Dec 2020, May 2023,
Dec 2023 |
| What is Introspection in Java Bean? | 3 | Dec 2019, Dec 2021,
May 2023 |
| What is JAR file? | 3 | Dec 2019, Dec 2020,
Dec 2021 |
| What are the components of RMI? | 3 | Dec 2019, Dec 2021,
Dec 2022 |
| What is RMI Registry? | 2 | May 2021, May 2023
|
| What is JDBC? | 2 | Dec 2022, May 2024
|
| Write the advantages of Java Beans. | 3 | Dec 2021, Dec 2022,
May 2024 |
| What is the usage of RMI over Inter-ORB Protocol? | 2 | Dec 2023, May 2023
|
| What is a bound property? | 2 | Dec 2020, May 2024
|
| State any two applications of RMI technology. | 2 | Dec 2022, May 2021
|
---
### ✅ **Repeated 6-Marks Questions (Total: 9)**
| Question | Times | Years
|
| -------------------------------------------- | ----- |
-------------------------------------- |
| Explain stubs and skeletons with an example. | 4 | Dec 2022, Dec 2023, Jun
2022, Jun 2023 |
| Discuss any three HTML form elements. | 3 | Dec 2022, Jun 2022, May
2024 |
| Explain servlet lifecycle. | 2 | Jun 2022, Dec 2023
|
| Discuss session tracking method in servlet. | 2 | Dec 2023, Jun 2023
|
| Short notes on JAR file in Java Beans. | 2 | Dec 2019, May 2024
|
| Explain the steps to create a new Java Bean. | 2 | Dec 2021, Jun 2022
|
| JSP scripting/directive elements. | 3 | Dec 2019, Dec 2023, Jun
2022 |
| Write short notes on RMI client. | 2 | Jun 2023, May 2024
|
| Applet to servlet communication. | 2 | Dec 2022, May 2024
|
---
### ✅ **Repeated 10-Marks Questions (Total: 8)**
| Question | Times | Years
|
| ------------------------------------------------------- | ----- |
---------------------------- |
| Explain RMI registry with example / procedure. | 3 | May 2021, Jun
2023, May 2024 |
| Explain JavaMail protocols / components. | 3 | Dec 2019, Dec
2021, Dec 2023 |
| Servlet chaining with example. | 2 | Dec 2022, Dec
2023 |
| Applet-servlet communication. | 2 | Dec 2021, Dec
2022 |
| Explain database connectivity in servlet. | 2 | Dec 2019, Jun
2023 |
| Explain Java Beans Development Kit (BDK) or Properties. | 2 | Dec 2023, Jun
2023 |
| Explain the types of EJB / Session bean with example. | 3 | Dec 2020, Dec
2022, May 2024 |
| Push data from RMI server. | 2 | Dec 2022, Jun
2022 |
---
Great! Since you've shared the **repeated questions** from previous exams, I’ll
begin answering them section by section, starting with the **2-mark questions**
(short answers), then proceed to 6-marks and finally 10-marks.
---
## ✅ **Repeated 2-Marks Questions – Answers**
### 1. **What is Java Bean?**
A **Java Bean** is a reusable software component that follows specific conventions:
* Public no-argument constructor
* Getter and setter methods for accessing properties
* Serializable
* Example:
```java
public class Student implements Serializable {
private String name;
public String getName() { return name; }
public void setName(String name) { [Link] = name; }
}
```
---
### 2. **What are the types of EJB?**
* **Session Beans** (stateless/stateful)
* **Entity Beans** (deprecated, replaced by JPA)
* **Message-Driven Beans (MDB)**
> Modern EJB focuses mainly on session and message-driven beans.
---
### 3. **What is Introspection in Java Bean?**
Introspection is the process of analyzing a Bean to:
* Discover its properties, events, and methods at runtime
* Done using **[Link]** class
---
### 4. **What is JAR file?**
JAR (Java ARchive) is a package file format that bundles:
* Multiple class files, metadata, and resources
* Into a single compressed file
* Example: `[Link]`
---
### 5. **What are the components of RMI?**
* **Remote Interface**
* **Stub and Skeleton** (skeleton deprecated after Java 1.2)
* **RMI Registry**
* **Remote Object Implementation**
* **Client**
---
### 6. **What is RMI Registry?**
A **name server** that allows clients to look up remote objects via logical names.
* Run using: `rmiregistry`
* Objects must be registered using `[Link]()`
---
### 7. **What is JDBC?**
**Java Database Connectivity** is an API for accessing relational databases.
* Interfaces: `Connection`, `Statement`, `ResultSet`
* Example: `[Link](...)`
---
### 8. **Write the advantages of Java Beans.**
* Platform independent
* Reusable and portable
* Supports property/event management
* Easy to manipulate using builder tools
---
### 9. **What is the usage of RMI over Inter-ORB Protocol (IIOP)?**
Allows Java RMI applications to interact with CORBA systems.
* Enables **interoperability** between Java and other CORBA-compliant languages
* Uses `[Link]`
---
### 10. **What is a bound property?**
A bound property notifies listeners when its value changes.
* JavaBeans use `PropertyChangeSupport` for this.
```java
[Link]("propertyName", oldVal, newVal);
```
---
### 11. **State any two applications of RMI technology.**
* Distributed banking applications
* Remote file access and editing
* Chat servers or distributed game engines
---
## ✅ **REVISED 6-Marks Questions – Detailed Answers**
---
### **1. Explain stubs and skeletons with an example.**
In Java RMI (Remote Method Invocation), **stubs and skeletons** facilitate
communication between a client and a remote object on the server.
#### 📌 Stub:
* A stub is a client-side proxy object for the remote object.
* It forwards the method invocation across the network to the actual remote object.
#### 📌 Skeleton (Java 1.1 only):
* Skeleton resided on the server and dispatched the call to the actual remote
object.
* Deprecated in Java 2; replaced by dynamically generated proxies.
#### ✅ Example:
```java
// Remote Interface
public interface Hello extends Remote {
String sayHello() throws RemoteException;
}
// Remote Object Implementation
public class HelloImpl extends UnicastRemoteObject implements Hello {
public HelloImpl() throws RemoteException {}
public String sayHello() { return "Hello from RMI Server!"; }
}
// Server Code
Hello obj = new HelloImpl();
[Link]("rmi://localhost:1099/HelloService", obj);
// Client Code
Hello stub = (Hello) [Link]("rmi://localhost:1099/HelloService");
[Link]([Link]());
```
---
### **2. Discuss any three HTML form elements.**
HTML forms collect user input and send it to a server (e.g., servlet or JSP).
Common elements include:
#### 1. **Text Field**
Used for single-line text input.
```html
<input type="text" name="username">
```
#### 2. **Radio Buttons**
Allow the user to select one option from a group.
```html
<input type="radio" name="gender" value="Male"> Male
<input type="radio" name="gender" value="Female"> Female
```
#### 3. **Submit Button**
Sends the form data to the server.
```html
<input type="submit" value="Submit">
```
These elements are essential for form-based web applications, where Java servlets
or JSP pages process submitted data.
---
### **3. Explain servlet lifecycle.**
A **Servlet** follows a well-defined lifecycle managed by the servlet container
(e.g., Apache Tomcat).
#### 🔁 Lifecycle Methods:
| Method | Description |
| ----------- | ----------------------------------------------------- |
| `init()` | Called once when the servlet is instantiated. |
| `service()` | Called for every request; handles `GET`, `POST`, etc. |
| `destroy()` | Called once when the servlet is unloaded. |
#### ✅ Example:
```java
public class MyServlet extends HttpServlet {
public void init() {
[Link]("Servlet initialized.");
}
protected void doGet(HttpServletRequest req, HttpServletResponse res) {
[Link]().println("Hello from servlet");
}
public void destroy() {
[Link]("Servlet destroyed.");
}
}
```
This model ensures efficient request handling by keeping the servlet in memory
during its lifetime.
---
### **4. Discuss session tracking methods in servlet.**
**Session tracking** allows a web application to maintain state across multiple
user requests.
#### 🧩 Common Techniques:
1. **Cookies**
Small data stored in the client browser.
```java
Cookie c = new Cookie("user", "john");
[Link](c);
```
2. **URL Rewriting**
Adds session info in the URL.
```java
[Link]("[Link]?user=john");
```
3. **Hidden Form Fields**
Uses `<input type="hidden">` to store data between forms.
4. **HttpSession API** (Most secure and widely used)
```java
HttpSession session = [Link]();
[Link]("user", "john");
```
These methods help maintain user data between page transitions, essential for login
systems, shopping carts, etc.
---
### **5. Short notes on JAR file in Java Beans.**
A **JAR (Java ARchive)** file packages Java classes and resources in a compressed
format, often used for JavaBeans distribution.
#### 📦 Advantages:
* Groups multiple `.class` files, images, metadata
* Simplifies distribution and deployment
* Supports **manifest file** with metadata (`Main-Class`, `Class-Path`)
#### ✅ Example:
```bash
jar cf [Link] [Link]
```
A JAR file can be loaded into visual builder tools to drag and drop components
(e.g., NetBeans, Eclipse).
---
### **6. Explain the steps to create a new Java Bean.**
Creating a Java Bean involves writing a class that follows specific conventions:
#### ✅ Steps:
1. **Create the Bean class**:
```java
public class StudentBean implements Serializable {
private String name;
public String getName() { return name; }
public void setName(String name) { [Link] = name; }
}
```
2. **Implement `Serializable`**: Enables bean to be persisted.
3. **Provide a no-argument constructor**.
4. **Use getter/setter methods** for accessing properties.
5. **Package as JAR (optional)**:
```bash
jar cf [Link] [Link]
```
These steps allow your bean to be used in GUI tools or server-side components.
---
### **7. JSP scripting/directive elements.**
#### ✍️ Scripting Elements:
1. **Scriptlet**: Embed Java code
```jsp
<% int a = 10; %>
```
2. **Expression**: Output value
```jsp
<%= a %>
```
3. **Declaration**: Declare methods or variables
```jsp
<%! int square(int x) { return x * x; } %>
```
#### ⚙️ Directive Elements:
1. **Page Directive**:
```jsp
<%@ page language="java" contentType="text/html" %>
```
2. **Include Directive**:
```jsp
<%@ include file="[Link]" %>
```
3. **Taglib Directive**:
Used with custom tag libraries like JSTL.
These elements give structure to JSPs and control compilation/behavior.
---
### **8. Write short notes on RMI client.**
A **Java RMI client** accesses and invokes methods on a remote object.
#### ✅ Client Responsibilities:
1. Look up the remote object using `[Link]`.
2. Cast it to the remote interface.
3. Call remote methods just like local ones.
#### 🧾 Example:
```java
Hello stub = (Hello) [Link]("rmi://localhost:1099/HelloService");
[Link]([Link]());
```
RMI clients simplify distributed applications by hiding the complexity of network
communication.
---
### **9. Applet to servlet communication.**
Applets can send data to servlets using **HTTP**.
#### ✅ Steps:
**Applet Side:**
```java
URL url = new URL("[Link]
URLConnection conn = [Link]();
[Link](true);
OutputStream os = [Link]();
[Link]("Hello Server".getBytes());
```
**Servlet Side:**
```java
BufferedReader reader = new BufferedReader(new
InputStreamReader([Link]()));
String msg = [Link]();
[Link]("Received: " + msg);
```
Used for client-server communication when applets handle UI and servlets handle
backend logic.
---
Perfect — let’s now go through the **10-mark repeated questions** with **lengthy,
structured, exam-level answers**, including definitions, explanations, and
code/examples where necessary. These are tailored to help you **score full marks**
in a University of Madras [Link]. IT exam.
---
## ✅ **10-Mark Repeated Questions – Detailed Answers**
---
### **1. Explain RMI registry with example/procedure.**
#### 🧩 What is RMI?
**Remote Method Invocation (RMI)** allows Java programs to invoke methods on an
object located in another JVM (usually on a different machine).
#### 🔒 What is RMI Registry?
* It's a **naming service** that allows remote clients to look up remote objects by
name.
* Works like a **DNS** for Java objects.
* Part of the `rmiregistry` tool provided by Java.
---
### 🧱 Steps to Use RMI Registry:
#### Step 1: Define the Remote Interface
```java
import [Link].*;
public interface Hello extends Remote {
String sayHello() throws RemoteException;
}
```
#### Step 2: Implement the Interface
```java
import [Link];
public class HelloImpl extends UnicastRemoteObject implements Hello {
public HelloImpl() throws RemoteException {
super();
}
public String sayHello() {
return "Hello from RMI Server";
}
}
```
#### Step 3: Create the Server and Register
```java
import [Link].*;
public class RMIServer {
public static void main(String[] args) {
try {
HelloImpl obj = new HelloImpl();
[Link]("rmi://localhost:1099/HelloService", obj);
[Link]("Server ready...");
} catch (Exception e) {
[Link]("Server Exception: " + e);
}
}
}
```
#### Step 4: Write the Client
```java
import [Link].*;
public class RMIClient {
public static void main(String[] args) {
try {
Hello stub = (Hello)
[Link]("rmi://localhost:1099/HelloService");
[Link]([Link]());
} catch (Exception e) {
[Link]("Client Exception: " + e);
}
}
}
```
#### Step 5: Compile and Run
```bash
javac *.java
rmiregistry &
java RMIServer
java RMIClient
```
---
### 📌 Advantages:
* Enables distributed application development
* Transparent remote method invocation
* Java-to-Java communication made simple
---
### **2. Explain JavaMail protocols and components.**
#### ✉️ What is JavaMail?
JavaMail API provides classes to send, receive, and compose emails using Java
programs.
---
### 📬 JavaMail Protocols:
| Protocol | Description
|
| -------- |
---------------------------------------------------------------------------- |
| SMTP | **Simple Mail Transfer Protocol** (for sending mail)
|
| POP3 | **Post Office Protocol** (for receiving mail, download and delete)
|
| IMAP | **Internet Message Access Protocol** (receiving and managing mail on
server) |
---
### 🔧 Core JavaMail Components:
1. **Session**: Configuration object for mail server.
```java
Session session = [Link](props);
```
2. **Message**: Represents the email.
```java
MimeMessage message = new MimeMessage(session);
```
3. **Transport**: Used to send the email.
```java
[Link](message);
```
4. **Store & Folder**: Used to read emails.
```java
Store store = [Link]("pop3");
Folder folder = [Link]("INBOX");
```
---
### ✅ Sending Email Example:
```java
Properties props = new Properties();
[Link]("[Link]", "[Link]");
Session session = [Link](props);
MimeMessage msg = new MimeMessage(session);
[Link](new InternetAddress("sender@[Link]"));
[Link]([Link], new
InternetAddress("receiver@[Link]"));
[Link]("Test");
[Link]("This is a test email.");
[Link](msg);
```
---
### 📌 Features:
* Attachment support
* MIME multipart
* Authentication and SSL/TLS support
---
### **3. Servlet chaining with example.**
#### 🔄 What is Servlet Chaining?
It is the **process of invoking multiple servlets sequentially** to handle a single
client request.
> Useful in filter-based architectures (e.g., logging, authentication).
---
### ✅ Example:
#### Servlet 1: `[Link]`
```java
public class AuthServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res) throws
IOException {
String user = [Link]("user");
if ("admin".equals(user)) {
[Link]("WelcomeServlet").forward(req, res);
} else {
[Link]().println("Unauthorized");
}
}
}
```
#### Servlet 2: `[Link]`
```java
public class WelcomeServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res) throws
IOException {
[Link]().println("Welcome, " + [Link]("user"));
}
}
```
#### [Link]
```xml
<servlet>
<servlet-name>AuthServlet</servlet-name>
<servlet-class>AuthServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>WelcomeServlet</servlet-name>
<servlet-class>WelcomeServlet</servlet-class>
</servlet>
```
---
### 📌 Benefits:
* Modular request processing
* Code reuse and separation of concerns
* Easier to maintain and debug
---
### **4. Applet-servlet communication.**
Java Applets can communicate with Servlets using `URLConnection`.
---
### ✅ Steps:
#### 1. Applet Code:
```java
URL url = new URL("[Link]
URLConnection conn = [Link]();
[Link](true);
OutputStream os = [Link]();
[Link]("Hello Server".getBytes());
[Link]();
```
#### 2. Servlet Code:
```java
BufferedReader br = new BufferedReader(new
InputStreamReader([Link]()));
String data = [Link]();
[Link]("Received from applet: " + data);
```
---
### 📌 Use Cases:
* Game score submission
* Remote data submission
* Client-side Java UI sending data to backend
---
### **5. Explain database connectivity in servlet.**
#### What is JDBC?
Java Database Connectivity (JDBC) is an API for connecting Java applications to
relational databases.
---
### ✅ Steps for JDBC in Servlets:
1. **Load the Driver**:
```java
[Link]("[Link]");
```
2. **Establish Connection**:
```java
Connection conn = [Link]("jdbc:mysql://localhost:3306/mydb",
"root", "pass");
```
3. **Create Statement**:
```java
PreparedStatement pst = [Link]("SELECT * FROM users");
```
4. **Execute and Process Results**:
```java
ResultSet rs = [Link]();
while ([Link]()) {
[Link]("User: " + [Link]("username"));
}
```
5. **Close Connection**:
```java
[Link]();
```
---
### 📌 Benefits:
* Real-time data access in web apps
* Easy CRUD operations
* Works with all major databases
---
Absolutely! Let's complete the remaining **10-mark repeated questions** with
**detailed, well-structured, and lengthy answers**, ideal for full-score answers in
university exams.
---
## ✅ **10-Mark Repeated Questions – Continued**
---
### **6. Explain JavaBeans Development Kit (BDK) or Properties.**
#### 🧠 What is JavaBean?
A **JavaBean** is a reusable software component written in Java that can be
manipulated visually in a builder tool.
#### 🧰 JavaBeans Development Kit (BDK):
The **BDK** is a development environment provided by Sun Microsystems to:
* Test and analyze JavaBeans components
* Visualize Bean properties, events, and methods
* Allow interaction among Beans
---
### 🔧 BDK Components:
1. **BeanBox**: Visual tool to load, test, and manipulate beans.
2. **Properties Sheet**: Displays editable bean properties.
3. **Method Tracer**: Shows methods called during testing.
4. **Event Monitor**: Shows event listeners and sources.
5. **JAR Manager**: For packaging and loading bean classes.
---
### ✅ Creating and Testing a Bean with BDK:
#### Step 1: Create Bean
```java
public class StudentBean implements Serializable {
private String name;
public String getName() { return name; }
public void setName(String name) { [Link] = name; }
}
```
#### Step 2: Package as JAR
```bash
jar cf [Link] [Link]
```
#### Step 3: Load into BDK
* Launch BDK (`[Link]`)
* Use **JAR Manager** to add your `[Link]`
* Drag the bean onto the BeanBox
* Set properties in the properties sheet
---
### ⚙️ JavaBean Properties
JavaBean properties are the internal state accessed through getter/setter methods.
#### Types of Properties:
1. **Simple** – A single value (e.g., `name`)
2. **Indexed** – Arrays or collections
3. **Bound** – Notifies listeners on change
4. **Constrained** – Can be vetoed by listeners
#### Example of Bound Property:
```java
private PropertyChangeSupport pcs = new PropertyChangeSupport(this);
public void setName(String name) {
String oldName = [Link];
[Link] = name;
[Link]("name", oldName, name);
}
```
---
### 📌 Advantages of BDK:
* Helps developers **visualize** and **test** JavaBeans
* No need to write GUI code
* Demonstrates **event delegation model**
---
### **7. Explain the types of EJB / Session beans with example.**
#### 🧩 What is EJB?
**Enterprise JavaBeans (EJB)** is a server-side software component that
encapsulates business logic of an enterprise application.
---
### 🧱 Types of Enterprise Beans:
| Type | Description |
| ------------------------------ | ------------------------------------------- |
| **Session Beans** | Handle user interaction logic |
| **Entity Beans** | Represent persistent data (replaced by JPA) |
| **Message-Driven Beans (MDB)** | Handle asynchronous messaging via JMS |
---
### ✅ Focus on **Session Beans**:
There are 2 main types:
1. **Stateless Session Beans**
* Do **not** retain client state between calls.
* Best for short operations (e.g., validation, login check).
```java
@Stateless
public class CalculatorBean {
public int add(int a, int b) {
return a + b;
}
}
```
2. **Stateful Session Beans**
* Maintain state for a single client session.
* Best for shopping cart, user sessions.
```java
@Stateful
public class CartBean {
private List<String> items = new ArrayList<>();
public void addItem(String item) { [Link](item); }
public List<String> getItems() { return items; }
}
```
---
### 📦 Deployment:
EJBs are deployed in a **JAR file** inside the `[Link]` file or using
annotations (Java EE 5+).
---
### 📌 Benefits of EJB:
* Simplified transaction management
* Declarative security
* Scalability and reusability
---
### **8. Push data from RMI Server.**
Normally, **clients pull data** from RMI servers. However, in **RMI Callbacks**,
servers can "push" data back to clients.
---
### 🧩 Key Idea:
* Client registers a callback object on the server.
* Server calls methods on this client-side object when needed.
---
### ✅ Step-by-Step Example
#### Step 1: Define Callback Interface
```java
public interface ClientCallback extends Remote {
void notifyClient(String message) throws RemoteException;
}
```
#### Step 2: Define Server Interface
```java
public interface Server extends Remote {
void register(ClientCallback client) throws RemoteException;
}
```
#### Step 3: Implement Server
```java
public class ServerImpl extends UnicastRemoteObject implements Server {
List<ClientCallback> clients = new ArrayList<>();
public void register(ClientCallback client) {
[Link](client);
}
public void broadcast(String message) {
for (ClientCallback client : clients) {
try {
[Link](message);
} catch (Exception e) {
[Link]("Client failed");
}
}
}
}
```
#### Step 4: Implement Client Callback
```java
public class ClientCallbackImpl extends UnicastRemoteObject implements
ClientCallback {
public void notifyClient(String message) {
[Link]("Received from server: " + message);
}
}
```
#### Step 5: Client Registers Callback
```java
ClientCallback callback = new ClientCallbackImpl();
Server server = (Server) [Link]("rmi://localhost:1099/Server");
[Link](callback);
```
---
### 📌 Real-World Use Cases:
* **Chat applications**
* **Stock price update notifications**
* **Sensor alert systems**
---
## 🎓 Summary: What You’ve Learned
You now have detailed, full-length answers on:
* RMI registry & callback (push data)
* JavaMail protocols & components
* Servlet chaining
* Applet-servlet communication
* JDBC in servlets
* JavaBean development & properties
* Session Beans in EJB
---