Skip to content

10xdev4u-alt/TFRx

Repository files navigation

πŸ”₯ ULTIMATE STUDY GUIDE - COMPLETE VISUALIZATION & 100+ VIVA! πŸ’―


πŸ“‹ TABLE OF CONTENTS

1. HTTP REQUEST
2. FTP FILE TRANSFER
3. SMTP EMAIL SENDER
4. POP3 EMAIL RECEIVER
5. RSS FEED PARSER
6. XML DOM PARSER
7. UDP CHAT APPLICATION
8. HTML IMAGE MAP WITH HOTSPOTS
9. HTML/CSS WEBSITE (3 CSS Types)
10. 100+ VIVA QUESTIONS & ANSWERS
11. QUICK REVISION CHEAT SHEETS
12. EXAM TIPS & TRICKS

πŸ“Œ EXPERIMENT 1: HTTP REQUEST

🎨 VISUAL FLOW

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    HTTP REQUEST FLOW                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

  JAVA PROGRAM                         WEB SERVER
       β”‚                                    β”‚
       β”‚  1. Create URL object              β”‚
       β”‚     URL url = new URL(...)         β”‚
       β”‚                                    β”‚
       β”‚  2. Open Connection                β”‚
       β”‚     HttpURLConnection conn         β”‚
       β”‚                                    β”‚
       β”‚  3. Set Method: GET                β”‚
       β”‚     conn.setRequestMethod("GET")   β”‚
       β”‚                                    β”‚
       β”‚  4. Send HTTP Request ────────────→│
       β”‚                                    β”‚
       β”‚                                    β”‚  Process Request
       β”‚                                    β”‚  Find Resource
       β”‚                                    β”‚
       β”‚  5. Receive Response ←─────────────│
       β”‚     - Status Code (200, 404, etc.) β”‚
       β”‚     - Headers                      β”‚
       β”‚     - Content (HTML/JSON)          β”‚
       β”‚                                    β”‚
       β”‚  6. Read Content                   β”‚
       β”‚     BufferedReader                 β”‚
       β”‚     readLine()                     β”‚
       β”‚                                    β”‚
       β”‚  7. Display Content                β”‚
       β”‚     System.out.println()           β”‚
       β”‚                                    β”‚
       ↓                                    ↓
     DONE                                 DONE

πŸ’» CODE STRUCTURE

// 1. CREATE URL
URL url = URI.create("https://www.google.com").toURL();

// 2. OPEN CONNECTION
HttpURLConnection conn = (HttpURLConnection) url.openConnection();

// 3. SET REQUEST METHOD
conn.setRequestMethod("GET");

// 4. GET RESPONSE
int code = conn.getResponseCode();        // 200, 404, etc.
String message = conn.getResponseMessage(); // OK, Not Found

// 5. READ CONTENT
BufferedReader in = new BufferedReader(
    new InputStreamReader(conn.getInputStream())
);

String line;
while ((line = in.readLine()) != null) {
    System.out.println(line);
}

// 6. CLOSE
in.close();
conn.disconnect();

🎯 KEY CONCEPTS

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  HTTP STATUS CODES                      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  200 - OK (Success)                     β”‚
β”‚  404 - Not Found                        β”‚
β”‚  500 - Internal Server Error            β”‚
β”‚  301 - Moved Permanently                β”‚
β”‚  403 - Forbidden                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  HTTP METHODS                           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  GET    - Retrieve data                 β”‚
β”‚  POST   - Send data                     β”‚
β”‚  PUT    - Update data                   β”‚
β”‚  DELETE - Delete data                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“Œ EXPERIMENT 2: FTP FILE TRANSFER

🎨 VISUAL FLOW

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   FTP FILE TRANSFER FLOW                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

    CLIENT                              SERVER
      β”‚                                    β”‚
      β”‚  1. Start Server                  β”‚
      β”‚                                    β”‚  ServerSocket ss = 
      β”‚                                    β”‚  new ServerSocket(5000)
      β”‚                                    β”‚  
      β”‚                                    β”‚  Waiting for client...
      β”‚                                    β”‚  socket = ss.accept()
      β”‚  2. Connect to Server              β”‚
      β”‚     Socket s = new Socket(         β”‚
      β”‚        "localhost", 5000)          β”‚
      β”‚  ──────────────────────────────────→  Connected!
      β”‚                                    β”‚
      β”‚  3. Enter Filename                 β”‚
      β”‚     "test.txt"                     β”‚
      β”‚  ──────────────────────────────────→  Received filename
      β”‚                                    β”‚
      β”‚                                    β”‚  4. Read File
      β”‚                                    β”‚     FileInputStream
      β”‚                                    β”‚     Read bytes
      β”‚                                    β”‚
      β”‚  5. Receive File Data              β”‚  5. Send File Data
      β”‚  ←──────────────────────────────────  OutputStream.write()
      β”‚     byte[] data                    β”‚
      β”‚                                    β”‚
      β”‚  6. Save File                      β”‚
      β”‚     FileOutputStream               β”‚
      β”‚     write(data)                    β”‚
      β”‚                                    β”‚
      β”‚  7. File Saved! βœ…                 β”‚  7. File Sent! βœ…
      β”‚                                    β”‚
      ↓                                    ↓
    DONE                                 DONE

πŸ’» CODE STRUCTURE

SERVER:

// 1. Create ServerSocket
ServerSocket server = new ServerSocket(5000);

// 2. Accept Client
Socket client = server.accept();

// 3. Get Filename
BufferedReader in = new BufferedReader(...);
String filename = in.readLine();

// 4. Read File
FileInputStream fileIn = new FileInputStream(filename);

// 5. Send File
OutputStream out = client.getOutputStream();
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = fileIn.read(buffer)) != -1) {
    out.write(buffer, 0, bytesRead);
}

// 6. Close
fileIn.close();
client.close();
server.close();

CLIENT:

// 1. Connect
Socket socket = new Socket("localhost", 5000);

// 2. Send Filename
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
out.println("test.txt");

// 3. Receive File
InputStream in = socket.getInputStream();
FileOutputStream fileOut = new FileOutputStream("received.txt");

byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = in.read(buffer)) != -1) {
    fileOut.write(buffer, 0, bytesRead);
}

// 4. Close
fileOut.close();
socket.close();

πŸ“Œ EXPERIMENT 3: SMTP EMAIL SENDER

🎨 VISUAL FLOW

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      SMTP EMAIL FLOW                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

  JAVA PROGRAM                    GMAIL SMTP SERVER
      β”‚                                  β”‚
      β”‚  1. Configure Properties         β”‚
      β”‚     - Host: smtp.gmail.com       β”‚
      β”‚     - Port: 587                  β”‚
      β”‚     - Auth: true                 β”‚
      β”‚     - STARTTLS: true             β”‚
      β”‚                                  β”‚
      β”‚  2. Create Session               β”‚
      β”‚     + Authentication             β”‚
      β”‚     (Username/Password)          β”‚
      β”‚                                  β”‚
      β”‚  3. Create Message               β”‚
      β”‚     - From: sender@gmail.com     β”‚
      β”‚     - To: receiver@gmail.com     β”‚
      β”‚     - Subject: "Hello"           β”‚
      β”‚     - Body: "Message text"       β”‚
      β”‚                                  β”‚
      β”‚  4. Send Email ─────────────────→│
      β”‚     Transport.send(message)      β”‚
      β”‚                                  β”‚
      β”‚                                  β”‚  5. Authenticate
      β”‚                                  β”‚     Verify credentials
      β”‚                                  β”‚
      β”‚                                  β”‚  6. Process Email
      β”‚                                  β”‚     Check recipient
      β”‚                                  β”‚     Validate format
      β”‚                                  β”‚
      β”‚                                  β”‚  7. Deliver to
      β”‚                                  β”‚     receiver's inbox
      β”‚                                  β”‚         ↓
      β”‚  8. Success! βœ…                  β”‚    RECEIVER'S
      β”‚                                  β”‚    INBOX πŸ“§
      ↓                                  ↓
    DONE                               DONE

πŸ’» CODE STRUCTURE

// 1. PROPERTIES
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.port", "587");

// 2. SESSION + AUTH
Session session = Session.getInstance(props, new Authenticator() {
    protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication(username, password);
    }
});

// 3. MESSAGE
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to));
message.setSubject(subject);
message.setText(body);

// 4. SEND
Transport.send(message);

🎯 KEY CONCEPTS

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  SMTP PORTS                             β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  25  - Default SMTP (often blocked)     β”‚
β”‚  587 - TLS/STARTTLS (RECOMMENDED) βœ…    β”‚
β”‚  465 - SSL/TLS (deprecated)             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  EMAIL COMPONENTS                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  From      - Sender email               β”‚
β”‚  To        - Recipient email            β”‚
β”‚  Subject   - Email title                β”‚
β”‚  Body      - Message content            β”‚
β”‚  Cc        - Carbon copy                β”‚
β”‚  Bcc       - Blind carbon copy          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“Œ EXPERIMENT 4: POP3 EMAIL RECEIVER

🎨 VISUAL FLOW

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     POP3 EMAIL FLOW                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

  JAVA PROGRAM                    GMAIL POP3 SERVER
      β”‚                                  β”‚
      β”‚  1. Configure Properties         β”‚
      β”‚     - Protocol: pop3             β”‚
      β”‚     - Host: pop.gmail.com        β”‚
      β”‚     - Port: 995                  β”‚
      β”‚     - SSL: true                  β”‚
      β”‚                                  β”‚
      β”‚  2. Create Session               β”‚
      β”‚     Session.getInstance()        β”‚
      β”‚                                  β”‚
      β”‚  3. Get Store                    β”‚
      β”‚     session.getStore("pop3")     β”‚
      β”‚                                  β”‚
      β”‚  4. Connect ────────────────────→│
      β”‚     store.connect(host, user, pass)β”‚
      β”‚                                  β”‚
      β”‚                                  β”‚  5. Authenticate
      β”‚                                  β”‚     Verify credentials
      β”‚                                  β”‚
      β”‚  6. Open Inbox                   β”‚
      β”‚     getFolder("INBOX")           β”‚
      β”‚     folder.open(READ_ONLY)       β”‚
      β”‚                                  β”‚
      β”‚  7. Request Messages ───────────→│
      β”‚     getMessages()                β”‚
      β”‚                                  β”‚
      β”‚  8. Download Emails ←───────────│
      β”‚     Message[] messages           β”‚
      β”‚                                  β”‚
      β”‚  9. Display Emails               β”‚
      β”‚     - From: msg.getFrom()        β”‚
      β”‚     - Subject: msg.getSubject()  β”‚
      β”‚     - Date: msg.getSentDate()    β”‚
      β”‚     - Content: msg.getContent()  β”‚
      β”‚                                  β”‚
      β”‚  10. Close Connection            β”‚
      β”‚      folder.close()              β”‚
      β”‚      store.close()               β”‚
      β”‚                                  β”‚
      ↓                                  ↓
    DONE                               DONE

πŸ’» CODE STRUCTURE

// 1. PROPERTIES
Properties props = new Properties();
props.put("mail.store.protocol", "pop3");
props.put("mail.pop3.host", "pop.gmail.com");
props.put("mail.pop3.port", "995");
props.put("mail.pop3.ssl.enable", "true");

// 2. SESSION
Session session = Session.getInstance(props);

// 3. CONNECT
Store store = session.getStore("pop3");
store.connect("pop.gmail.com", username, password);

// 4. OPEN INBOX
Folder inbox = store.getFolder("INBOX");
inbox.open(Folder.READ_ONLY);

// 5. GET MESSAGES
Message[] messages = inbox.getMessages();

// 6. READ EMAILS
for (Message msg : messages) {
    System.out.println("From: " + msg.getFrom()[0]);
    System.out.println("Subject: " + msg.getSubject());
    System.out.println("Date: " + msg.getSentDate());
}

// 7. CLOSE
inbox.close(false);
store.close();

πŸ“Œ EXPERIMENT 5: RSS FEED PARSER

🎨 VISUAL FLOW

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    RSS FEED PARSER FLOW                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

  JAVA PROGRAM                    RSS FEED SERVER
      β”‚                                  β”‚
      β”‚  1. Create URL                   β”‚
      β”‚     "towardsdatascience.com/feed"β”‚
      β”‚                                  β”‚
      β”‚  2. Request Feed ───────────────→│
      β”‚     URL.openStream()             β”‚
      β”‚                                  β”‚
      β”‚                                  β”‚  3. Generate XML
      β”‚                                  β”‚     <rss>
      β”‚  4. Receive XML ←───────────────│     <channel>
      β”‚                                  β”‚       <item>...</item>
      β”‚                                  β”‚     </channel>
      β”‚                                  β”‚     </rss>
      β”‚  5. Parse XML                    β”‚
      β”‚     DocumentBuilder.parse()      β”‚
      β”‚                                  β”‚
      β”‚  6. Extract Channel Info         β”‚
      β”‚     - Title                      β”‚
      β”‚     - Description                β”‚
      β”‚     - Last Build Date            β”‚
      β”‚                                  β”‚
      β”‚  7. Get All Items                β”‚
      β”‚     getElementsByTagName("item") β”‚
      β”‚                                  β”‚
      β”‚  8. Loop Through Articles        β”‚
      β”‚     For each <item>:             β”‚
      β”‚       - Title                    β”‚
      β”‚       - Link                     β”‚
      β”‚       - Description              β”‚
      β”‚       - Publication Date         β”‚
      β”‚       - Author                   β”‚
      β”‚       - Category                 β”‚
      β”‚                                  β”‚
      β”‚  9. Display Articles             β”‚
      β”‚     System.out.println()         β”‚
      β”‚                                  β”‚
      ↓                                  ↓
    DONE                               DONE

πŸ’» CODE STRUCTURE

// 1. LOAD RSS
String url = "https://towardsdatascience.com/feed/";
Document doc = DocumentBuilderFactory.newInstance()
    .newDocumentBuilder()
    .parse(new URL(url).openStream());

doc.getDocumentElement().normalize();

// 2. GET CHANNEL INFO
Element channel = (Element) doc.getElementsByTagName("channel").item(0);
String title = channel.getElementsByTagName("title").item(0).getTextContent();

// 3. GET ALL ITEMS
NodeList items = doc.getElementsByTagName("item");

// 4. LOOP THROUGH
for (int i = 0; i < items.getLength(); i++) {
    Element item = (Element) items.item(i);
    
    String itemTitle = item.getElementsByTagName("title").item(0).getTextContent();
    String link = item.getElementsByTagName("link").item(0).getTextContent();
    String desc = item.getElementsByTagName("description").item(0).getTextContent();
}

🎯 RSS STRUCTURE

<rss version="2.0">
  <channel>                  <!-- Feed container -->
    <title>Feed Name</title>
    <link>Feed URL</link>
    <description>About</description>
    
    <item>                   <!-- Article 1 -->
      <title>Article Title</title>
      <link>Article URL</link>
      <description>Summary</description>
      <pubDate>Date</pubDate>
      <author>Author Name</author>
    </item>
    
    <item>                   <!-- Article 2 -->
      ...
    </item>
  </channel>
</rss>

πŸ“Œ EXPERIMENT 6: XML DOM PARSER

🎨 VISUAL FLOW

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    XML PARSING FLOW                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

  JAVA PROGRAM                    XML FILE (students.xml)
      β”‚                                  β”‚
      β”‚  1. Create DocumentBuilder       β”‚
      β”‚     Factory + Builder            β”‚
      β”‚                                  β”‚
      β”‚  2. Load XML File ──────────────→│
      β”‚     parse(new File("..."))       β”‚
      β”‚                                  β”‚
      β”‚  3. Parse into Tree              β”‚  <students>
      β”‚                                  β”‚    <student id="101">
      β”‚      DOM TREE IN MEMORY:         β”‚      <name>Raj</name>
      β”‚                                  β”‚      <cgpa>8.5</cgpa>
      β”‚      students (root)             β”‚    </student>
      β”‚         β”‚                        β”‚  </students>
      β”‚         β”œβ”€ student (id=101)      β”‚
      β”‚         β”‚    β”œβ”€ name (Raj)       β”‚
      β”‚         β”‚    └─ cgpa (8.5)       β”‚
      β”‚         β”‚                        β”‚
      β”‚         └─ student (id=102)      β”‚
      β”‚              β”œβ”€ name (Priya)     β”‚
      β”‚              └─ cgpa (9.2)       β”‚
      β”‚                                  β”‚
      β”‚  4. Normalize Tree               β”‚
      β”‚     doc.normalize()              β”‚
      β”‚                                  β”‚
      β”‚  5. Get Elements                 β”‚
      β”‚     getElementsByTagName("student")β”‚
      β”‚                                  β”‚
      β”‚  6. Loop Through Nodes           β”‚
      β”‚     For each student:            β”‚
      β”‚       - Get ID attribute         β”‚
      β”‚       - Get name element         β”‚
      β”‚       - Get CGPA element         β”‚
      β”‚                                  β”‚
      β”‚  7. Display Data                 β”‚
      β”‚     System.out.println()         β”‚
      β”‚                                  β”‚
      ↓                                  ↓
    DONE                               DONE

πŸ’» CODE STRUCTURE

CREATING XML:

// 1. CREATE DOCUMENT
DocumentBuilder builder = DocumentBuilderFactory.newInstance()
    .newDocumentBuilder();
Document doc = builder.newDocument();

// 2. CREATE ROOT
Element root = doc.createElement("students");
doc.appendChild(root);

// 3. CREATE STUDENT
Element student = doc.createElement("student");
student.setAttribute("id", "101");

Element name = doc.createElement("name");
name.setTextContent("Rajesh");
student.appendChild(name);

root.appendChild(student);

// 4. WRITE TO FILE
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.transform(new DOMSource(doc), new StreamResult(new File("students.xml")));

PARSING XML:

// 1. LOAD XML
Document doc = DocumentBuilderFactory.newInstance()
    .newDocumentBuilder()
    .parse(new File("students.xml"));

doc.getDocumentElement().normalize();

// 2. GET ELEMENTS
NodeList students = doc.getElementsByTagName("student");

// 3. LOOP
for (int i = 0; i < students.getLength(); i++) {
    Element student = (Element) students.item(i);
    
    String id = student.getAttribute("id");
    String name = student.getElementsByTagName("name").item(0).getTextContent();
}

πŸ“Œ EXPERIMENT 7: UDP CHAT APPLICATION

🎨 VISUAL FLOW

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   UDP CHAT FLOW (2-WAY)                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

  PERSON A (Port 5000)              PERSON B (Port 6000)
      β”‚                                    β”‚
      β”‚  1. Create Socket                 β”‚  1. Create Socket
      β”‚     DatagramSocket(5000)          β”‚     DatagramSocket(6000)
      β”‚                                    β”‚
      β”‚  2. Start Receiver Thread         β”‚  2. Start Receiver Thread
      β”‚     (Background listening)         β”‚     (Background listening)
      β”‚                                    β”‚
      β”‚  Main Thread Ready                β”‚  Main Thread Ready
      β”‚  (Waiting for user input)         β”‚  (Waiting for user input)
      β”‚                                    β”‚
      β”‚  3. User types: "Hello"           β”‚
      β”‚                                    β”‚
      β”‚  4. Create Packet                 β”‚
      β”‚     - Data: "Hello"               β”‚
      β”‚     - Dest: localhost:6000        β”‚
      β”‚                                    β”‚
      β”‚  5. Send Packet ─────────────────→│  6. Receiver Thread
      β”‚     socket.send()                 β”‚     receives packet
      β”‚                                    β”‚
      β”‚                                    β”‚  7. Display: "Hello"
      β”‚                                    β”‚
      β”‚                                    β”‚  8. User types: "Hi!"
      β”‚                                    β”‚
      β”‚                                    β”‚  9. Create Packet
      β”‚                                    β”‚     - Data: "Hi!"
      β”‚                                    β”‚     - Dest: localhost:5000
      β”‚                                    β”‚
      β”‚  10. Receiver Thread              β”‚  11. Send Packet
      β”‚      receives packet  ←───────────│      socket.send()
      β”‚                                    β”‚
      β”‚  12. Display: "Hi!"               β”‚
      β”‚                                    β”‚
      β”‚  ↕️  CHAT CONTINUES...  ↕️         β”‚
      ↓                                    ↓

πŸ’» CODE STRUCTURE

// 1. CREATE SOCKET
int myPort = 5000;
int friendPort = 6000;
DatagramSocket socket = new DatagramSocket(myPort);
InetAddress friendAddress = InetAddress.getByName("localhost");

// 2. RECEIVER THREAD
new Thread(() -> {
    byte[] buffer = new byte[1024];
    while (true) {
        DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
        socket.receive(packet);  // WAIT for message
        String msg = new String(packet.getData(), 0, packet.getLength());
        System.out.println("Friend: " + msg);
    }
}).start();

// 3. SENDER (Main Thread)
Scanner sc = new Scanner(System.in);
while (true) {
    String msg = sc.nextLine();
    byte[] data = msg.getBytes();
    DatagramPacket packet = new DatagramPacket(data, data.length, 
                                                friendAddress, friendPort);
    socket.send(packet);
}

🎯 KEY CONCEPTS

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  TCP vs UDP                             β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  TCP:                                   β”‚
β”‚  - Connection-oriented                  β”‚
β”‚  - Reliable delivery                    β”‚
β”‚  - Ordered packets                      β”‚
β”‚  - Slower                               β”‚
β”‚                                         β”‚
β”‚  UDP: βœ… Used in chat                   β”‚
β”‚  - Connectionless                       β”‚
β”‚  - No delivery guarantee                β”‚
β”‚  - Faster                               β”‚
β”‚  - Good for: Chat, Gaming, Streaming    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  DatagramPacket Components              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  - Data (byte[])                        β”‚
β”‚  - Length (int)                         β”‚
β”‚  - Destination Address (InetAddress)    β”‚
β”‚  - Destination Port (int)               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“Œ EXPERIMENT 8: HTML IMAGE MAP WITH HOTSPOTS

🎨 VISUAL FLOW

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                 IMAGE MAP HOTSPOT FLOW                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

  USER                        BROWSER                   JAVASCRIPT
   β”‚                              β”‚                          β”‚
   β”‚  1. Page Loads               β”‚                          β”‚
   β”‚  ────────────────────────────→                          β”‚
   β”‚                              β”‚                          β”‚
   β”‚                              β”‚  2. Render Image         β”‚
   β”‚                              β”‚     + Hotspot areas      β”‚
   β”‚                              β”‚                          β”‚
   β”‚  3. Click on Hotspot         β”‚                          β”‚
   β”‚     (e.g., North India)      β”‚                          β”‚
   β”‚  ────────────────────────────→                          β”‚
   β”‚                              β”‚                          β”‚
   β”‚                              β”‚  4. Trigger onclick      β”‚
   β”‚                              β”‚  ──────────────────────→ β”‚
   β”‚                              β”‚                          β”‚
   β”‚                              β”‚                          β”‚  5. Execute
   β”‚                              β”‚                          β”‚     showInfo('north')
   β”‚                              β”‚                          β”‚
   β”‚                              β”‚                          β”‚  6. Hide all boxes
   β”‚                              β”‚                          β”‚     classList.remove()
   β”‚                              β”‚                          β”‚
   β”‚                              β”‚                          β”‚  7. Show selected
   β”‚                              β”‚  ←──────────────────────│     classList.add()
   β”‚                              β”‚                          β”‚
   β”‚  8. Display Information      β”‚                          β”‚
   β”‚  ←───────────────────────────                          β”‚
   β”‚     Info box appears         β”‚                          β”‚
   β”‚     with details             β”‚                          β”‚
   β”‚                              β”‚                          β”‚
   β”‚  9. User can close           β”‚                          β”‚
   β”‚     or click another area    β”‚                          β”‚
   β”‚                              β”‚                          β”‚
   ↓                              ↓                          ↓

πŸ’» CODE STRUCTURE

<!-- 1. IMAGE WITH USEMAP -->
<img src="map.jpg" usemap="#mymap">

<!-- 2. MAP DEFINITION -->
<map name="mymap">
    <!-- 3. HOTSPOT AREAS -->
    
    <!-- Rectangle -->
    <area shape="rect" 
          coords="x1,y1,x2,y2" 
          onclick="showInfo('area1')">
    
    <!-- Circle -->
    <area shape="circle" 
          coords="x,y,radius" 
          onclick="showInfo('area2')">
    
    <!-- Polygon -->
    <area shape="poly" 
          coords="x1,y1,x2,y2,x3,y3,..." 
          onclick="showInfo('area3')">
</map>

<!-- 4. INFORMATION BOXES -->
<div id="info-area1" class="info-box">
    <h2>Area 1 Information</h2>
    <p>Details here...</p>
</div>

<!-- 5. JAVASCRIPT -->
<script>
function showInfo(id) {
    // Hide all
    document.querySelectorAll('.info-box').forEach(box => {
        box.style.display = 'none';
    });
    
    // Show selected
    document.getElementById('info-' + id).style.display = 'block';
}
</script>

🎯 SHAPE COORDINATES

RECTANGLE:
coords="x1,y1,x2,y2"

(x1,y1)────────┐
   β”‚           β”‚
   β”‚           β”‚
   └────────(x2,y2)

CIRCLE:
coords="x,y,radius"

      (x,y)
       ●
      β•± β•²
     β”‚   β”‚
      β•² β•±

POLYGON:
coords="x1,y1,x2,y2,x3,y3,x4,y4"

    (x2,y2)
      β•± β•²
(x1,y1)   (x3,y3)
      β•² β•±
    (x4,y4)

πŸ“Œ EXPERIMENT 9: HTML/CSS WEBSITE (3 CSS TYPES)

🎨 CSS TYPES VISUAL

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    3 TYPES OF CSS                           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

1️⃣  EXTERNAL CSS (styles.css)
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ styles.css                       β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
    β”‚ body {                           β”‚
    β”‚   background: white;             β”‚
    β”‚ }                                β”‚
    β”‚                                  β”‚
    β”‚ .header {                        β”‚
    β”‚   color: blue;                   β”‚
    β”‚ }                                β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              ↓ Linked via
    <link rel="stylesheet" href="styles.css">
    
    βœ… Global styles
    βœ… Reusable across pages
    βœ… Cacheable

2️⃣  INTERNAL CSS (<style> tag)
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ <style>                          β”‚
    β”‚   .hero-section {                β”‚
    β”‚     background: linear-gradient();β”‚
    β”‚     animation: fadeIn 1s;        β”‚
    β”‚   }                              β”‚
    β”‚ </style>                         β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    
    βœ… Page-specific styles
    βœ… Animations
    βœ… Special effects

3️⃣  INLINE CSS (style attribute)
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ <h1 style="color: red;           β”‚
    β”‚            font-size: 2em;">     β”‚
    β”‚   Title                          β”‚
    β”‚ </h1>                            β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    
    βœ… Unique element styling
    βœ… Quick changes
    βœ… Highest priority

🎯 CSS PRIORITY

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  CSS SPECIFICITY (Priority Order)     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                        β”‚
β”‚  1. INLINE CSS (Highest) ⭐⭐⭐        β”‚
β”‚     <h1 style="color: red;">           β”‚
β”‚                                        β”‚
β”‚  2. INTERNAL CSS ⭐⭐                  β”‚
β”‚     <style>.class { }</style>          β”‚
β”‚                                        β”‚
β”‚  3. EXTERNAL CSS (Lowest) ⭐           β”‚
β”‚     <link rel="stylesheet">            β”‚
β”‚                                        β”‚
β”‚  If conflict: Inline wins!             β”‚
β”‚                                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🎯 100+ POWER-PACKED VIVA QUESTIONS!

πŸ“š SECTION 1: HTTP REQUEST (15 Questions)

Q1: What is HTTP?

HTTP (HyperText Transfer Protocol) is an application-layer 
protocol for transmitting hypermedia documents like HTML. 
It's the foundation of data communication on the web.

Q2: What is the difference between HTTP and HTTPS?

HTTP: Unencrypted, data sent in plain text, port 80
HTTPS: Encrypted using SSL/TLS, secure, port 443

Q3: What are HTTP methods?

- GET: Retrieve data from server
- POST: Send data to server
- PUT: Update existing data
- DELETE: Delete data
- HEAD: Get headers only
- OPTIONS: Get supported methods

Q4: Explain HTTP status codes.

1xx - Informational (100 Continue)
2xx - Success (200 OK, 201 Created)
3xx - Redirection (301 Moved, 302 Found)
4xx - Client Error (404 Not Found, 403 Forbidden)
5xx - Server Error (500 Internal Server Error)

Q5: What is HttpURLConnection?

A class in java.net package for HTTP-specific operations.
It extends URLConnection and provides methods to set 
request method, get response code, and read response content.

Q6: What is URL?

Uniform Resource Locator - specifies the location of a 
resource on the internet. Format:
protocol://hostname:port/path?query#fragment

Q7: Why use URI.create() instead of new URL()?

URL(String) constructor is deprecated in newer Java versions.
URI.create().toURL() provides better validation and security.

Q8: What is BufferedReader?

A class that reads text from input stream efficiently by 
buffering characters. Provides readLine() method for reading 
line by line.

Q9: What does getResponseCode() return?

Returns an integer representing HTTP status code:
200 (OK), 404 (Not Found), 500 (Server Error), etc.

Q10: What is the purpose of setRequestMethod()?

Sets the HTTP method for the request (GET, POST, PUT, DELETE).
Default is GET if not specified.

Q11: Difference between GET and POST?

GET:
- Retrieves data
- Parameters in URL
- Visible in browser history
- Limited data size
- Cacheable

POST:
- Sends data
- Parameters in request body
- Not visible in URL
- Unlimited size
- Not cacheable

Q12: What is InputStreamReader?

Bridge from byte streams to character streams. Reads bytes 
and decodes them into characters using specified charset.

Q13: How to handle connection timeout?

connection.setConnectTimeout(5000);  // 5 seconds
connection.setReadTimeout(5000);

Q14: What is User-Agent header?

Identifies the client software making the request.
Example: "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
Can be set using: connection.setRequestProperty("User-Agent", "...")

Q15: How to close HTTP connection properly?

reader.close();           // Close BufferedReader
connection.disconnect();  // Close connection

πŸ“š SECTION 2: FTP FILE TRANSFER (15 Questions)

Q16: What is FTP?

File Transfer Protocol - network protocol for transferring 
files between client and server over TCP/IP connections.

Q17: What is Socket?

An endpoint for communication between two machines. 
Combines IP address and port number. Provides bidirectional 
communication channel.

Q18: What is ServerSocket?

Used by server to listen for incoming client connections.
Creates a socket that waits on a specific port for client 
connection requests.

Q19: Difference between Socket and ServerSocket?

Socket:
- Used by client to connect
- Used by server after accepting connection
- Created with host and port

ServerSocket:
- Used only by server
- Listens for connections
- Created with port only

Q20: What does accept() method do?

Blocks (waits) until a client connects. When client connects,
returns a Socket object for communication with that client.

Q21: Explain TCP vs UDP.

TCP:
- Connection-oriented
- Reliable, ordered delivery
- Error checking
- Slower
- Used for: File transfer, Email, Web

UDP:
- Connectionless
- No delivery guarantee
- Faster
- Used for: Chat, Gaming, Streaming

Q22: What is InputStream?

Abstract class for reading byte streams. Provides read() 
method to read bytes from source (file, network, etc.)

Q23: What is OutputStream?

Abstract class for writing byte streams. Provides write() 
method to write bytes to destination.

Q24: What is FileInputStream?

Reads bytes from a file. Opens connection to actual file 
and provides methods to read file content as bytes.

Q25: What is FileOutputStream?

Writes bytes to a file. Creates/overwrites file and provides 
methods to write byte data to file.

Q26: Why use byte buffer in file transfer?

Instead of reading/writing one byte at a time, buffer reads 
multiple bytes (e.g., 1024 bytes) at once, making transfer 
much faster and efficient.

Q27: What is port number?

16-bit number (0-65535) identifying a specific process/service.
0-1023: Well-known ports (HTTP=80, HTTPS=443)
1024-49151: Registered ports
49152-65535: Dynamic/private ports

Q28: How to know when file transfer is complete?

while ((bytesRead = in.read(buffer)) != -1) {
    // -1 indicates end of stream
}

Q29: What is InetAddress?

Represents an IP address. Provides methods:
- getByName("localhost") - Get address by hostname
- getLocalHost() - Get local machine address
- getHostAddress() - Get IP as string

Q30: Why close sockets?

To release system resources (memory, file descriptors, ports).
Prevents resource leaks and allows port reuse.

πŸ“š SECTION 3: SMTP & POP3 (20 Questions)

Q31: What is SMTP?

Simple Mail Transfer Protocol - used for sending emails from 
client to server and between servers. Port 587 (TLS), 465 (SSL).

Q32: What is POP3?

Post Office Protocol version 3 - used for retrieving emails 
from server to client. Downloads emails and optionally deletes 
from server. Port 995 (SSL).

Q33: Difference between SMTP and POP3?

SMTP:
- Sends emails
- Port 587/465
- Outgoing mail server
- Uses Transport class

POP3:
- Receives emails
- Port 995
- Incoming mail server
- Uses Store/Folder classes

Q34: What is IMAP?

Internet Message Access Protocol - alternative to POP3.
Keeps emails on server, syncs across devices. Port 993.

Q35: SMTP vs IMAP vs POP3?

SMTP: Sending only
POP3: Download and delete (offline access)
IMAP: Sync and keep on server (online access)

Q36: What is JavaMail API?

Java library for sending and receiving emails using SMTP, 
POP3, IMAP protocols. Provides Session, Message, Transport,
Store classes.

Q37: Why use App Password for Gmail?

Google requires app-specific passwords for 2-factor 
authentication. Regular password won't work for third-party 
apps for security reasons.

Q38: What is Session in JavaMail?

Represents a mail session. Stores configuration (SMTP host, 
port, authentication) and manages connection to mail server.

Q39: What is MimeMessage?

Represents an email message. Contains From, To, Subject, Body,
and other email headers. Extends Message class.

Q40: What is Transport.send()?

Static method that sends an email message. Takes Message 
object, connects to SMTP server, authenticates, and sends email.

Q41: What is Store in POP3?

Represents connection to email server. Provides access to 
folders (INBOX, Sent, etc.) for retrieving messages.

Q42: What is Folder in POP3?

Represents a mailbox folder (INBOX, Drafts, etc.).
Can be opened in READ_ONLY or READ_WRITE mode.

Q43: What ports does SMTP use?

25  - Default SMTP (often blocked)
587 - STARTTLS (recommended)
465 - SSL/TLS (deprecated but used)

Q44: What is STARTTLS?

Command that upgrades plain text connection to encrypted 
TLS/SSL connection. Used on port 587 for secure email 
transmission.

Q45: Explain email components.

From: Sender email
To: Recipient email
Cc: Carbon copy (visible to all)
Bcc: Blind carbon copy (hidden)
Subject: Email title
Body: Message content
Attachments: Files attached

Q46: How to add attachments in JavaMail?

MimeBodyPart attachment = new MimeBodyPart();
attachment.attachFile(new File("file.pdf"));

Multipart multipart = new MimeMultipart();
multipart.addBodyPart(attachment);
message.setContent(multipart);

Q47: What is Properties object in JavaMail?

Stores configuration key-value pairs:
- mail.smtp.host
- mail.smtp.port
- mail.smtp.auth
- mail.smtp.starttls.enable

Q48: What is Authenticator?

Abstract class for password authentication. Override 
getPasswordAuthentication() to provide username and password 
to email server.

Q49: How to read email content?

Object content = message.getContent();
if (content instanceof String) {
    String text = (String) content;
}

Q50: What is InternetAddress?

Represents an email address. Parses and validates email 
format. Used for From, To, Cc, Bcc fields.

πŸ“š SECTION 4: XML & RSS (20 Questions)

Q51: What is XML?

eXtensible Markup Language - markup language for storing 
and transporting data. Self-descriptive, platform-independent,
human and machine readable.

Q52: What is DOM Parser?

Document Object Model Parser - loads entire XML into memory 
as tree structure. Allows random access, navigation, and 
modification of XML.

Q53: DOM vs SAX Parser?

DOM:
- Loads entire XML into memory
- Tree structure
- Random access
- Can modify XML
- Good for small files

SAX:
- Event-based, sequential
- Memory efficient
- Forward-only
- Cannot modify
- Good for large files

Q54: What is DocumentBuilder?

Class that parses XML and creates Document object. Created 
using DocumentBuilderFactory. Provides parse() method.

Q55: What is Document in DOM?

Represents entire XML document as tree structure. Root of 
DOM tree. Provides methods to access and manipulate XML.

Q56: What is Element in DOM?

Represents an XML element (tag). Has tag name, attributes,
text content, and child elements. Main building block of XML.

Q57: What is Node in DOM?

Base interface for all DOM objects. Everything is a node:
elements, attributes, text, comments. Element extends Node.

Q58: What does normalize() do?

Removes empty text nodes and merges adjacent text nodes.
Cleans up XML structure for easier parsing.

Q59: What is NodeList?

Ordered collection of nodes. Like an array but not exactly.
Access using item(index) method. Has getLength() method.

Q60: How to get element text?

element.getElementsByTagName("name").item(0).getTextContent();

Breakdown:
- getElementsByTagName() - Find all matching tags
- item(0) - Get first element
- getTextContent() - Get text inside

Q61: How to get attribute value?

element.getAttribute("id");

Returns value of "id" attribute as String.

Q62: How to create XML programmatically?

Document doc = builder.newDocument();
Element root = doc.createElement("root");
doc.appendChild(root);

Q63: What is Transformer?

Converts DOM Document to XML file. Sets formatting options 
like indentation. Used with TransformerFactory.

Q64: What is RSS?

Really Simple Syndication - XML format for distributing 
web content (news, blogs, podcasts). Allows users to subscribe 
to updates.

Q65: RSS structure?

<rss version="2.0">
  <channel>
    <title>Feed Title</title>
    <item>
      <title>Article Title</title>
      <link>Article URL</link>
      <description>Summary</description>
    </item>
  </channel>
</rss>

Q66: What is in RSS?

Container for feed information and items. Contains feed title,
description, link, and collection of <item> elements.

Q67: What is in RSS?

Represents one article/post in feed. Contains title, link,
description, publication date, author, categories.

Q68: How to parse RSS from internet?

URL url = new URL("https://example.com/feed/");
Document doc = builder.parse(url.openStream());

Q69: What is CDATA?

<description><![CDATA[Text with <html> tags]]></description>

Character Data section - contains text that should not be 
parsed as XML. Used for HTML content in descriptions.

Q70: Why use XML for data?

- Platform independent
- Human readable
- Self-descriptive
- Hierarchical structure
- Widely supported
- Extensible

πŸ“š SECTION 5: UDP CHAT (15 Questions)

Q71: What is UDP?

User Datagram Protocol - connectionless transport protocol.
Sends datagrams without establishing connection. Faster but 
unreliable.

Q72: What is DatagramSocket?

Socket for sending and receiving UDP packets. Can both send 
and receive using same socket. No connection establishment.

Q73: What is DatagramPacket?

Container for UDP data. Contains:
- Data (byte array)
- Length
- Destination IP address
- Destination port

Q74: How to create DatagramSocket?

// Client (any port)
DatagramSocket socket = new DatagramSocket();

// Server (specific port)
DatagramSocket socket = new DatagramSocket(9876);

Q75: How to send UDP packet?

byte[] data = message.getBytes();
DatagramPacket packet = new DatagramPacket(
    data, data.length, address, port
);
socket.send(packet);

Q76: How to receive UDP packet?

byte[] buffer = new byte[1024];
DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
socket.receive(packet);  // Blocks until packet arrives
String message = new String(packet.getData(), 0, packet.getLength());

Q77: Why use threading in chat?

Without threading: Can only send OR receive at a time.
With threading: 
- Main thread handles sending
- Receiver thread handles receiving
- Both run simultaneously

Q78: What is daemon thread?

thread.setDaemon(true);

Daemon thread automatically terminates when main thread ends.
Used for background tasks like receiving messages.

Q79: How to get sender information?

String senderIP = packet.getAddress().getHostAddress();
int senderPort = packet.getPort();

Q80: UDP vs TCP for chat?

UDP (Better for chat):
+ Faster
+ No connection overhead
+ Good for real-time
- No delivery guarantee
- May lose packets

TCP:
+ Reliable
+ Ordered delivery
- Slower
- Connection overhead

Q81: What is localhost?

Hostname referring to current machine. IP: 127.0.0.1
Used for testing on same computer.

Q82: Can UDP packets arrive out of order?

Yes! UDP doesn't guarantee order. If you send packet 1, 2, 3,
they might arrive as 2, 1, 3. Application must handle ordering.

Q83: What is maximum UDP packet size?

Theoretical: 65,535 bytes
Practical: 1472 bytes (to avoid fragmentation)
Best practice: Keep under 512 bytes for reliability

Q84: How to implement group chat with UDP?

Send packet to multiple addresses:
for (InetAddress addr : friendAddresses) {
    DatagramPacket packet = new DatagramPacket(..., addr, port);
    socket.send(packet);
}

Q85: What happens if port is already in use?

BindException: Address already in use

Solution:
- Use different port
- Close existing program using that port
- Use socket.setReuseAddress(true) before binding

πŸ“š SECTION 6: HTML & CSS (20 Questions)

Q86: What is HTML?

HyperText Markup Language - standard markup language for 
creating web pages. Uses tags to structure content.

Q87: What is CSS?

Cascading Style Sheets - language for styling HTML elements.
Controls layout, colors, fonts, spacing, animations.

Q88: Three types of CSS?

1. External CSS - Separate .css file, linked with <link>
2. Internal CSS - Inside <style> tag in HTML
3. Inline CSS - style attribute on HTML element

Q89: Which CSS has highest priority?

Inline CSS > Internal CSS > External CSS

If conflict, inline wins!

Q90: What is tag?

Defines an image map with clickable areas. Contains <area> 
elements that define hotspot regions.

Q91: What is tag?

Defines a clickable hotspot in image map. Attributes:
- shape: rect, circle, poly
- coords: coordinates
- alt: alternative text
- onclick: JavaScript function

Q92: What shapes are supported in image map?

1. rect (Rectangle): coords="x1,y1,x2,y2"
2. circle: coords="x,y,radius"
3. poly (Polygon): coords="x1,y1,x2,y2,x3,y3,..."

Q93: What is usemap attribute?

<img src="map.jpg" usemap="#mapname">
<map name="mapname">

Links image to its map definition. Must match with # symbol.

Q94: Rectangle coordinates explained?

coords="x1,y1,x2,y2"

(x1,y1) = Top-left corner
(x2,y2) = Bottom-right corner

Example: coords="10,20,100,80"

Q95: Circle coordinates explained?

coords="x,y,radius"

(x,y) = Center point
radius = Circle radius in pixels

Example: coords="150,150,50"

Q96: Polygon coordinates explained?

coords="x1,y1,x2,y2,x3,y3,x4,y4,..."

Multiple (x,y) pairs for each vertex.
Connects points in order to form polygon.

Q97: What is onclick in HTML?

Event attribute that executes JavaScript when element is 
clicked. 

Example: onclick="showInfo('north')"

Q98: What is classList in JavaScript?

element.classList.add('active');     // Add class
element.classList.remove('active');  // Remove class
element.classList.toggle('active');  // Toggle class

Manages CSS classes on elements.

Q99: What is querySelector?

document.querySelector('.classname');   // First match
document.querySelectorAll('.classname'); // All matches

Selects HTML elements using CSS selectors.

Q100: What is addEventListener?

element.addEventListener('click', function() {
    // Code here
});

Attaches event handler to element. Better than onclick.

πŸ“š SECTION 7: GENERAL NETWORKING (15 Questions)

Q101: What is IP address?

Unique numerical identifier for devices on network.
IPv4: 192.168.1.1 (32-bit)
IPv6: 2001:0db8:... (128-bit)

Q102: What is port?

16-bit number (0-65535) identifying specific service/process.
Like apartment number in building (IP is building address).

Q103: What is localhost?

Hostname for local machine. Always resolves to 127.0.0.1.
Used for testing on same computer.

Q104: What is client-server model?

Client: Requests services
Server: Provides services

Example: Web browser (client) requests page from web server.

Q105: What is protocol?

Set of rules for communication between devices.
Examples: HTTP, FTP, SMTP, POP3, TCP, UDP

Q106: OSI Model layers?

7. Application (HTTP, SMTP, FTP)
6. Presentation
5. Session
4. Transport (TCP, UDP)
3. Network (IP)
2. Data Link
1. Physical

Q107: What is TCP 3-way handshake?

1. Client β†’ Server: SYN
2. Server β†’ Client: SYN-ACK
3. Client β†’ Server: ACK

Establishes connection before data transfer.

Q108: What is firewall?

Security system that monitors and controls network traffic.
Can block ports, protocols, or IP addresses.

Q109: What is DNS?

Domain Name System - translates domain names to IP addresses.
Example: google.com β†’ 142.250.192.46

Q110: What is URL structure?

protocol://hostname:port/path?query#fragment

Example:
https://example.com:443/page?id=5#section

Q111: What is socket programming?

Programming technique for network communication using sockets.
Allows applications on different machines to communicate.

Q112: What is bandwidth?

Maximum data transfer rate of network connection.
Measured in bits per second (bps, Kbps, Mbps, Gbps).

Q113: What is latency?

Time delay for data to travel from source to destination.
Measured in milliseconds (ms). Lower is better.

Q114: What is packet?

Unit of data transmitted over network. Contains:
- Header (source, destination, protocol info)
- Payload (actual data)
- Footer (error checking)

Q115: What is MAC address?

Media Access Control - unique hardware identifier for network 
interface. 48-bit (6 bytes). Example: 00:1A:2B:3C:4D:5E

πŸ“ QUICK REVISION CHEAT SHEETS

🎯 JAVA NETWORKING CLASSES

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  CLASS                PURPOSE                  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  URL                  Web address              β”‚
β”‚  HttpURLConnection    HTTP requests            β”‚
β”‚  Socket               TCP client connection    β”‚
β”‚  ServerSocket         TCP server listener      β”‚
β”‚  DatagramSocket       UDP socket               β”‚
β”‚  DatagramPacket       UDP data container       β”‚
β”‚  InetAddress          IP address               β”‚
β”‚  BufferedReader       Read text efficiently    β”‚
β”‚  PrintWriter          Write text easily        β”‚
β”‚  InputStream          Read bytes               β”‚
β”‚  OutputStream         Write bytes              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🎯 PORTS QUICK REFERENCE

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  SERVICE        PORT       PROTOCOL            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  HTTP           80         TCP                 β”‚
β”‚  HTTPS          443        TCP                 β”‚
β”‚  FTP            21         TCP                 β”‚
β”‚  SMTP           587        TCP (TLS)           β”‚
β”‚  SMTP SSL       465        TCP                 β”‚
β”‚  POP3           995        TCP (SSL)           β”‚
β”‚  IMAP           993        TCP (SSL)           β”‚
β”‚  DNS            53         UDP/TCP             β”‚
β”‚  SSH            22         TCP                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🎯 HTTP STATUS CODES

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  CODE    MEANING           DESCRIPTION         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  200     OK                Success             β”‚
β”‚  201     Created           Resource created    β”‚
β”‚  301     Moved Permanently Redirected          β”‚
β”‚  400     Bad Request       Invalid request     β”‚
β”‚  401     Unauthorized      Auth required       β”‚
β”‚  403     Forbidden         Access denied       β”‚
β”‚  404     Not Found         Resource missing    β”‚
β”‚  500     Server Error      Server crashed      β”‚
β”‚  503     Unavailable       Server overloaded   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🎯 EMAIL PROTOCOLS

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  PROTOCOL   PURPOSE        PORT    SECURITY   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  SMTP       Send email     587     TLS        β”‚
β”‚  POP3       Download email 995     SSL        β”‚
β”‚  IMAP       Sync email     993     SSL        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸŽ“ EXAM TIPS & TRICKS

βœ… CODING EXAM STRATEGY

1. READ QUESTION CAREFULLY (2 min)
   - Underline key requirements
   - Note if client/server needed

2. WRITE STRUCTURE FIRST (3 min)
   - Import statements
   - Class + main method
   - Try-catch block

3. FILL IN CODE (10 min)
   - Follow algorithm given
   - Use meaningful variable names
   - Add comments

4. TEST MENTALLY (2 min)
   - Trace through logic
   - Check for missing closes

5. WRITE OUTPUT (3 min)
   - Sample input/output
   - Expected results

βœ… VIVA PREPARATION

GOLDEN RULES:
1. Speak CLEARLY and CONFIDENTLY
2. If don't know, say "I'll check and learn"
3. Never guess randomly
4. Relate to your code
5. Use diagrams if helpful

SAMPLE ANSWER STRUCTURE:
"Sir, [CONCEPT] is [DEFINITION]. 
 It is used for [PURPOSE].
 In my program, I used [PRACTICAL EXAMPLE]."

Example:
"Sir, Socket is an endpoint for communication 
 between two machines. It is used for network 
 programming. In my FTP program, I used Socket 
 to connect client to server on port 5000."

βœ… COMMON MISTAKES TO AVOID

❌ Forgetting to close connections
❌ Not handling exceptions
❌ Wrong port numbers
❌ Missing imports
❌ Forgetting to start server before client
❌ Not checking null values
❌ Mixing up send/receive logic
❌ Forgetting setRequestMethod() in HTTP
❌ Not normalizing XML document
❌ Missing usemap in image map

πŸ† FINAL CHECKLIST

πŸ“‹ BEFORE EXAM

β˜‘ Practiced all 9 experiments
β˜‘ Can write code from memory
β˜‘ Understand flow diagrams
β˜‘ Memorized 20+ viva questions
β˜‘ Know all port numbers
β˜‘ Remember to close connections
β˜‘ Understand TCP vs UDP
β˜‘ Know HTTP status codes
β˜‘ Can explain DOM parsing
β˜‘ Understand image map coordinates
β˜‘ Sleep well night before! 😴

πŸ“‹ IN EXAM ROOM

β˜‘ Read question twice
β˜‘ Plan before coding
β˜‘ Write clean code
β˜‘ Add comments
β˜‘ Check for errors
β˜‘ Write sample output
β˜‘ Stay calm! 😊

🎯 LAST MINUTE REVISION (15 MINUTES)

MINUTE 1-3: HTTP Request
- URL β†’ HttpURLConnection β†’ GET β†’ Response Code β†’ BufferedReader

MINUTE 4-6: FTP
- ServerSocket.accept() β†’ FileInputStream β†’ send bytes β†’ close

MINUTE 7-9: SMTP/POP3
- SMTP: Session β†’ Message β†’ Transport.send()
- POP3: Store β†’ Folder β†’ getMessages()

MINUTE 10-12: XML/RSS
- DocumentBuilder β†’ parse() β†’ getElementsByTagName() β†’ getTextContent()

MINUTE 13-15: UDP Chat
- DatagramSocket β†’ DatagramPacket β†’ send()/receive() β†’ Threading

πŸ”₯ YOU'RE ABSOLUTELY READY!

βœ… 9 Experiments - MASTERED!
βœ… 115+ Viva Questions - PREPARED!
βœ… Visual Diagrams - CLEAR!
βœ… Code Structure - UNDERSTOOD!
βœ… Quick References - READY!
βœ… Exam Strategy - PLANNED!

CONFIDENCE LEVEL: πŸ’―πŸ’―πŸ’―
ALL THE BEST! πŸ’ͺ😎

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors