0% found this document useful (0 votes)
3 views2 pages

Java Programming Assignment 3

Uploaded by

shaikmehnazanjum
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Java Programming Assignment 3

Uploaded by

shaikmehnazanjum
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Java Programming Assignment 3

Question 1:
Write a Java program that demonstrates user input and file handling. The program should
prompt the user to enter their complete name (the student should enter his/her first and
last name) and a text file name, append the complete name to the specified file content, read
the file's content, and display it on the console.

Clarifications:
1. Use the Scanner class to read user input for the file name.
2. Append your complete name to the specified file, then read and display the file's content
on the console.
3. Handle any possible errors, such as file not found or input mismatch exceptions.

Question 2:
Write a Java program that demonstrates the use of exceptions for error handling. The
program should handle a divide by zero exception and display an appropriate message.

Clarifications:
1. Implement try-catch blocks to handle exceptions.
2. Simulate a division by zero operation and catch the ArithmeticException.
3. Display 'Division by zero is not possible' if a division by zero occurs.

Expected Output:
Enter numerator: 10
Enter denominator: 0
Division by zero is not possible.

Question 3:
Write a Java program that demonstrates BufferedReader for reading input from the user.
The program should read a user's name and age, then display them in a message.

Clarifications:
1. Use BufferedReader to read user input for name and age.
2. Use the readLine() method to read strings and the parseInt() method to read integers.
3. Display the user's name and age in a formatted message.
Expected Output:
Enter your name: John Doe
Enter your age: 30
Hello, John Doe! You are 30 years old.

Question 4:
Write a Java program that demonstrates the use of ArrayLists, LinkedLists, and HashSet
from the Collections Framework. The program should add elements to each of these
collections and display them.

Clarifications:
1. Create an ArrayList and add a few elements. Display the ArrayList.
2. Create a LinkedList, add elements, and display the LinkedList.
3. Create a HashSet, add elements, and display the HashSet.
4. Explain the differences between ArrayList, LinkedList, and HashSet.

Submission Guidelines:
1. Create a folder on your Google Drive for the assignment.
2. Take full-screen screenshots of each task, including both the complete code and the
executed output from your system's IDE (online compiler screenshots are not valid).
3. Do not crop or edit the screenshots in any way to maintain clarity.
4. Upload the full-screen screenshots into the folder.
5. After uploading the screenshots, get the shareable link to the folder.
6. Submit the shareable link in the assignment submission section.

You might also like