DEPARTMENT OF COMPUTER SCIENCE
SIKKIM MANIPAL INSTITUTE OF TECHNOLOGY
JAVA PROGRAMMING (CS201A3/CSML201A3/CSIC201A3)
PROGRAMMING IN JAVA CS528A3
ASSIGNMENT
Note: Submit on A4 size paper
Last Date of submission : 15/11/2025
Q1. What is garbage collection in programming, and why is it important
for memory management in languages such as Java compared to C and C++?
Q2. Explain the concept of random access files in Java. Write a Java
program using the RandomAccessFile class to perform the following
operations on a binary file named [Link]:
Write records of students, where each record contains:
• A 4-digit integer ID
• A fixed-length 20-character name
• Read a specific student record by seeking directly to its
position in the file using the student ID as an index (assume
records are stored sequentially starting from ID = 1).
• Update the name of a student given their ID.
• Display all student records stored in the file.
Your program should:
• Use fixed-length records to enable predictable seeking.
• Include proper error handling (e.g., file not found, invalid
ID).
• Display meaningful output for each operation.
[Note: Attach screenshots of the program output for submission.]
Q3. Explain how client-server communication works in Java using TCP
sockets.
Q4. List and describe any three key networking classes and interfaces
provided in the [Link] package.
Q5. Create a Java Applet that simulates a simple Login Page using AWT
components and the Delegation Event Model.
The applet should allow the user to enter a username and password,
and display an appropriate message such as “Login Successful” or
“Invalid Credentials” after clicking the Login button.
Attach screenshots of: - Login form before entering credentials -
Successful login - Invalid login attempt.
Follow the following instructions while making the applet.
1
Step Task Requirement
Design the Applet
Create the following components inside
1 Interface using AWT
your applet:
Controls
Label Add a Label with the text “Username”.
TextField (Username) Add a TextField for entering the username.
Add another Label with the text
Label
“Password”.
Add a TextField for password input and
TextField (Password) use setEchoChar('*') to mask the
password.
Add a Button labeled “Login” to trigger
Button
the event.
Add a Label or TextArea to display status
Label / TextArea messages such as “Login Successful” or
“Invalid Credentials”.
Implement Event
2 Handling (Delegation Handle button click using ActionListener.
Event Model)
Register an ActionListener for the Login
Register Listener
button.
When the button is clicked, verify the
Event Logic
entered username and password.
Use predefined credentials: username =
Condition Check
admin, password = 1234.
Show the corresponding message on the
Display Result
applet (success or failure).