Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
11 views5 pages

NPTEL Java Enhanced Topics Final

The document covers several Java topics not included in Edureka videos, including Java Applets, AWT, Servlets, and Java Networking. It provides definitions, analogies, lifecycles, key components, and example code for each topic. The content serves as a supplementary guide for understanding these Java concepts and their practical applications.

Uploaded by

biswastushar672
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)
11 views5 pages

NPTEL Java Enhanced Topics Final

The document covers several Java topics not included in Edureka videos, including Java Applets, AWT, Servlets, and Java Networking. It provides definitions, analogies, lifecycles, key components, and example code for each topic. The content serves as a supplementary guide for understanding these Java concepts and their practical applications.

Uploaded by

biswastushar672
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/ 5

### Java Topics Not Covered in Edureka Video (Based on NPTEL PDF + Detailed Additions)

---

## 1. Java Applets

Definition:

Applets are small Java programs embedded in web pages, running inside a Java-enabled browser. They are used for

interactive tasks like games or visualizations.

Analogy: Like a mini game that loads inside a website - similar to an embedded YouTube video, but it's Java code.

Lifecycle:

- init() - Called once during loading.

- start() - Resumes applet execution.

- paint(Graphics g) - Handles visual drawing.

- stop() - Pauses the applet.

- destroy() - Cleanup before removal.

Example:

import java.applet.Applet;

import java.awt.Graphics;

public class HelloApplet extends Applet {

public void paint(Graphics g) {

g.drawString("Welcome to Applet", 20, 20);

HTML:

<applet code="HelloApplet.class" width="300" height="200"></applet>

---
## 2. Abstract Window Toolkit (AWT)

Definition:

AWT is Java's platform-dependent GUI library. It allows creation of windows, buttons, and forms.

Analogy: AWT is like Lego blocks you use to build basic GUI apps.

Components:

Frame, Button, Label, TextField, TextArea, Checkbox, Choice

Event Handling:

- Delegation model: event source -> listener -> handler.

- Common interfaces: ActionListener, WindowListener

Example:

import java.awt.*;

import java.awt.event.*;

public class AWTExample {

public static void main(String[] args) {

Frame f = new Frame("AWT Example");

Label l = new Label("Enter your name:");

TextField tf = new TextField();

Button b = new Button("Submit");

l.setBounds(50, 50, 150, 20);

tf.setBounds(50, 80, 150, 20);

b.setBounds(50, 110, 60, 30);

f.add(l); f.add(tf); f.add(b);

f.setSize(300, 200);

f.setLayout(null);

f.setVisible(true);

}
}

---

## 3. Java Servlets

Definition:

Servlets are Java programs that run on a web server and dynamically generate web content.

Analogy: A servlet is like a waiter - takes your request (order), processes it (kitchen), and returns a response (food).

Lifecycle:

- init()

- service()

- destroy()

HTTP Methods:

- doGet() for fetching data

- doPost() for submitting data

Example:

import java.io.*;

import javax.servlet.*;

import javax.servlet.http.*;

public class HelloServlet extends HttpServlet {

public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {

res.setContentType("text/html");

PrintWriter out = res.getWriter();

out.println("<h1>Hello from Servlet</h1>");

---
## 4. Java Networking

Definition:

Java Networking enables communication between devices using TCP/IP.

Analogy: Like a visitor sending a message to a receptionist (client-server communication).

Key Classes:

Socket - Client side

ServerSocket - Server side

DataInputStream / DataOutputStream - Transfer data

Example:

Server:

import java.io.*;

import java.net.*;

public class Server {

public static void main(String[] args) throws IOException {

ServerSocket ss = new ServerSocket(5000);

Socket s = ss.accept();

DataInputStream dis = new DataInputStream(s.getInputStream());

String message = dis.readUTF();

System.out.println("Client says: " + message);

ss.close();

Client:

import java.io.*;

import java.net.*;

public class Client {


public static void main(String[] args) throws IOException {

Socket s = new Socket("localhost", 5000);

DataOutputStream dout = new DataOutputStream(s.getOutputStream());

dout.writeUTF("Hello Server");

dout.flush();

dout.close();

s.close();

You might also like