0% found this document useful (0 votes)
20 views

Core_Adv_Java_Assignmentsuwaechiuiaebc

The document outlines a series of programming assignments in Java, categorized by weeks, covering various concepts such as array manipulation, object-oriented programming, exception handling, and data structures like ArrayList, LinkedList, HashSet, and HashMap. Each assignment includes specific tasks such as reversing arrays, calculating areas, implementing classes, and handling user input. The assignments are designed to enhance understanding of Java programming and its applications.

Uploaded by

palaayush341
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Core_Adv_Java_Assignmentsuwaechiuiaebc

The document outlines a series of programming assignments in Java, categorized by weeks, covering various concepts such as array manipulation, object-oriented programming, exception handling, and data structures like ArrayList, LinkedList, HashSet, and HashMap. Each assignment includes specific tasks such as reversing arrays, calculating areas, implementing classes, and handling user input. The assignments are designed to enhance understanding of Java programming and its applications.

Uploaded by

palaayush341
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

12. Write a program to reverse elements in array?

(last element go to first position


and vice-versa)

13. Write a program to sort array in descending order?

14. Write a program to find maximum element in array.

15. Write a program to Input two 3 X 3 Array and perform below operation:-

1 - Addition

2 – Multiplication

CORE JAVA ASSGINMENTS

Week – 1

1. Program to find area and circumference of a circle. (Use Fixed Data , Do


not take values from user)

2. Program to calculate sum of marks of 3 subjects and find


percentage marks.(Take input via command line arguments)

3. Program to calculate simple interest. (Take input from keyboard via


Scanner class object)

4. Program that accepts number of days as integer value and display total
number of years , months and days in it.
5. Program to convert temparature from farenheit to celsius . Use formula (C= 5
* (f – 32) / 9)

result should be displayed with decimal point.

6. Program to swap 2 numbers without using third variable.(Take input


from keyborad via BufferedReader class object)

7. Program to swap 2 numbers using third variable.(Take input from


keyborad via BufferedReader class object)

8. Program to print full name entered by user in reverse order. (Only words are to
be reveresed not the characters inside it and Take input via command line
arguments)
9. Program that accepts 2 numbers via command line arguments and prints next
2
adjacent even numbers after them.

10. Program that prints features of java in systematic way as we get to see in
books with proper formatting. Use tab , white spaces , new line characters to
provide definition term and definition data type layout.

Week – 2

1. Program to reverse a user entered number.

2. Program to check whether entered year is leap year or not.

3. In a company an empoyee is paid as given below:

1) If basic salary of empoyee is less than Rs. 1500 , then HRA = 10% of basic

salary and DA = 90 % of basic salary

2) If basic salary is greater tahn or equal to Rs. 1500 , then HRA = Rs. 500 and
DA = 98% of basic salary

Accept basic salary as input and calculate HRA , DA AND Total Salary
of employee

4. Program to print table of any user entered number.

5. Print Lucas Series starting from any user entered number (up to 10 values) : 1, 2
, 3 , 6 , 11 , 20 , 37 , ......

6. Program to sort a 10 element array in desceding order.

7. Program to multiply two 3 by 3 matrices.

8. Create a class to calculate Area of circle with one data member to store the
radius and another to store area value. Create following member methods :
1) init() : to input radius from user

2) calc() : to calculate area

3) display() : to display area

9. Create a class Person with properties (name and age) with following features :

1) Default age of person should be 18

2) A parameterised constructor to initialise Person object.

3) Method to diplsay name and age of person.

10. Create a class Product(pid,price,quantity) with parameterised constructor.


Create a main() in different class (say XYZ) and perform following task :

1) Accept five product information from user and store in an array.


2) Find pid of product with highest price.

3) Create method (with array of product's object as argument) in XYZ class to


calculate and return total amount spent on all products.(amount spent on

single product = price of product * quantity of product)

Week – 3

1. Create a class Tile to store the edge length of a square tile and create
another class Floor to store length and width of a rectangular floor. Add
method totalTiles(Tile t) in Floor class with Tile as argument to clculate
the whole number of tiles needed to cover the floor completely.

2. Write a program to find average of passed numbers to a method. The method


should be able to accept as many number of arguments as user wants to send.

3. Create a class MathOperation containing method multiply() to


calculate multiplication of following arguments :

1) two integer

2) three double values

3) all elements of array

4) one double and one integer

4. Create a class OneBHK with instance variable roomArea , hallArea and


price. a) Create default and parameterised constructor

b) method show() - to print OneBHK area information.


Create another class TwoBHK which has all the properties and behaviour of

OneBHK and a new instance variable room2Area.

5. Create a class Student with teo members : rollno and percentage

a) Create default and parameterised constructors.

b) Create method show() to display infomation.

c) Create another class CollegeStudent that inherits Student class. Add a new
member semester to it.Create default and parameterised constructors , also

override show() method.

d) Create another class SchoolStudent that inherits Student class. Add a


new member classname(e.g. 10Th , 12th) to it. Create default and

parameterised constructors, also override show() method.

e) Create a class XYZ with main() that carries out following operations -

i) has array to store objects of any class(Student or CollegeStudent


or SchoolStudent)

ii) Create two CollegeStudent and three SchoolStudent record objects and stire

iii) them inside the array.

iii) Display all records from the array.

iv) Search record on the basis of rollno nad check given rollno is of
SchoolStudent or of CollegeStudent

6. Create an abstract class Processor with int member variable – data and method
- showData() to display data value. Create an abstract method process() to
define procesing of member data.

a) Create a class Factorial using abstract class Processor to calculate and print

factorial of a number by overriding the process() method.

b) Create a class Circle using abstract class Processor to calculate and print
area of circle by overriding the process() method.

c) Ask user to enter choice (factorial or circle area). Alo ask data to work upon ,

useProcessor class reference to achieve this mechanism.

Week – 4

1. Create following classes / package structure in your java application.

Package Name Class Name

campus.data
Person(name, age ,address)

campus.academics
1)Student(rollno, breanch, semester) inherits Person

2)Faculty(facultyId, name , salary,

branch) inherits Person

3) CampusApp – this class contains

main() to accept 5 faculty info and print

total of salaries of all faculties

campus.accounts
Fees(Student, amount , paymentDate)

Campus
CampusApp – this class contains main()
to accept 4 students info with their fees
for second semester and print total fees
collected fromall 4 students
Create this application as a runnable jar.

2. Input data exactly in the following format and print sum of all integer values.

“67,89,23,67,12,55,66”(Hint: use String class split() and Integer class parseInt()


method)

3 . Create interface Taxable with members – salesTax = 7% and incomeTax = 10.5%.

Create abstract method calcTax():

a) Create class Employee (empid,name,salary) and implement Taxable


to calculate incomeTax on yearly Salary.

b) Create class Product (pid,price,quantity) and implement Tazable to calculate


salesTax on unit price of product.

c) Create class for main() , accept employee information and a product


information from user and print income tax and sales tax respectively.

4. Create a method process() that will accept an integer number as a parameter and
depending on user's choice calculate a) reverse b) square c) half of the number .
(process() should appear only once in the code , overloading is not allowed.)

5. Demonstrate use of StringJoiner class with a meaningful program.

6 . Demonstrate default and static method in interface with a java program


7. Input name of a person and count how many vowels it contains. Use String
class functions.

Week – 5

1. Store name of weekdays in an array (starting from “Sunday” at 0 index). Ask


day position from user and print day name. Handle ArrayIndexOutOfBounds
Exception and give proper message if user enters day index out of (0 to 6).

2. Create a class Worker(workerId,name,age) with a parameterised constructor.


Check() should throw a checked custom(user defined) exception if age is less
than 16. The message of exception should be “Invalid Age For Worker”.

3. Create an interface StudentFee and declare following method.

void printFees(int fees) throws IllegalArgumentException . Design a case from

your side where for certain value of parameter fees , IllegalArgumentException


should be raised.

4. Create a class Employee(eno,ename,deptname). Make sure that :

a) eno and ename should be printed on screen when Employee object is printed

b) two employee objects should be compared depending on their eno.

5. Write a program to store your shopping details in a binary file(shopping.dat) with


infomation itemName , price , quantity (use ObjectOutputStream to store Item class
object)

6. Write a p[rogram to read data from above created shopping.dat file and find total
money spent on all shopping items. (use ObjectInputStream to store Item class object)

7. Write a program to count total no. Of bytes in an image file saved on your PC. Also
find find how much time will it take to upload the file on server if internet speed is
256 bps(bits per second)

Week – 6

1 . Print following pattern on screen with delay of 2 second between each print of *.

***

**

2. Write a program to demonstrate concept of wait() and notify() in following cases :


a) If a reader is reading from a file no writer should be allowed to write to the file

b) If a writer is writing to a file no other writer shoudl be allowed to write to the file.

3. Write a java program to demonstrate concept of synchronization in java.

Demonstrate the scenario where Printer can print only one document at a time.

4. Design a Frame based application as shown below figure and on click of button
display

button's text on given Label.


5. Design a Frame based application as shown below figure and show entered
detail inside

TextArea when user clicks on submit button.


6. Create a Calculator to perform arithmetical Operation by designing Frame like:
7.Create a Temperature Converter by designing Frame like:
8. Design a Frame based application as shown below

And perform following task:

- On click of >>, selected element of list1 should be transferred to list2


- On click of <<, selected element of list2 should be transferred to list1

- On click of >>>, all elements of list1 should be transferred to list2

- On click of <<<, all element of list2 should be transferred to list1

9. Design a Frame and perform following task:

If User type any City in the text Field and click on Add button then it should be added
in

JCombobox. And in a Joptionpane, a message should be displayed “city added”. If user


clicks

on Add button without enter any text then a message should be displayed “Please
Enter city

name ”.

ADVANCE JAVA ASSIGNMENTS

Week 1

1) Write a java program to create ArrayList of any type and perform following operations :
1) Add elements to arraylist and print them using for-each loop

2) Add elements to arraylist and print them using Iterator

3) Ask for position and new element from user , check if the position is valid and then
insert the user entered element at that position

4) Ask for position from user and then retrieve the element at that position , proper
error message should be displayed if the position is invalid.

5) Ask for position from user and then delete the element at that position , proper
error message should be displayed if the position is invalid.

6) Ask for position from user and the new element and then replace the element at
that position , proper error message should be displayed if the position is invalid.

7) Ask for element from user and then delete that element from the arraylist , proper
error message should be displayed if the element is not present in the list.

8) Convert the arraylist into an array

2) Write a java program to create ArrayList of Account type and perform following
operations :

class Account

private int balance;


private String acct_number;

1) Store Account class objects into the arraylist.

2) Sort the elements of the arraylist based on ascending order of their acct_number.

3) Sort the elements of the arraylist based on descending order of their balance.

4) Whenever any element of the arraylist is printed the balance and acct_number of
the accounts should be printed.

3) Write a java program to create LinkedList of any type and perform following operations :

1) demonstrate use of methods received by LinkedList from Queue interface.

2) demonstrate use of methods received by LinkedList from Deque interface.

3) print elements of the linkedlist in reverse order

4) repeat an element in the linkedlist and then display index of the element's first
occurance and last occurance.

5) empty the contencts of the linkedlist.

4) Write a java program to create HashSet of Mobile type and perform following operations :

class Mobile
{

private int price;

private String maker;

1) Store objects of Mobile class into the HashSet.

2) Ask for mobile price from user and then display the mobile's price and maker if it is
present in the HashSet , if not display proper message on screen.

3) If any Mobile object is repeated , it should not be saved into the HashSet again.

4) Ask for mobile maker from user and then delete that Mobile object from the
HashSet , if not present , display proper message on screen.

5) Write a java program to create TreeSet of Voter type and perform following operations :

class Voter

private int age;

private String name;

1) Store objects of Voter class into the TreeSet , sorting should happen on the basis of
Voter's age.
2) Ask for age of Voter from user and then display the Voter's age and name if it is
present in the TreeSet , if not display proper message on screen.

3) Ask for Voter's name from user and then delete that Voter object from the HashSet
, if not present , display proper message on screen. If multiple voter's with same name exist ,
delete all of them.

6) Write a java program to create HashMap where key should be of the type Integer and
value should be of the type String and perform following operations :

1) Store some key-value pair enrites in the HashMap.

2) Display list of all keys from the HashMap.

3) Display list of all entries from the HashMap.

4) Ask for key, original value and new value from user , check if the any entry with the
specified key already exists if yes then replace the original value by the new value.

5) Ask for key from user , if the any entry with the specified key exists then delete the
entry else display proper message on screen.

6) Ask for key, value from user , check if the any entry with the specified key and the
value already exists if yes then delete the entry else no changes are to be done.

7) Write a java program to create TreeMap where key should be of the type Student class
and value should be of the type String (Value will represent Student's Name) and perform
following operations :
class Student

private Integer rollno;

private Character division;

1) Store some key-value pair enrites in the TreeMap.

2) Display list of all keys from the HashMap (combination of rollno and division should
be displayed).

3) Sort the entries on the basis of rollno of Student.

4) Display list of all entries from the HashMap.

Week 2 :

1) Create following database design using sql :

1) QuestionCategory table:

Column Column_Type

id int (Primary Key : Auto Increment)


categoryName varchar(40) (unique)

2) QuestionSubCategory table:

Column Column_Type

id int (Primary Key : Auto Increment)

subCategoryName varchar(60) (unique)

categoryID int (Foreign Key references id from QuestionCategory table)

3) Question table:

Column Column_Type

id int (Primary Key : Auto Increment)

desc varchar(200)

categoryID int (Foreign Key references id from QuestionCategory table)

subCategoryID int (Foreign Key references id from QuestionSubCategory table)

postedDate date

status boolean

visibility boolean

*) Store records into above tables using SQL

*) Display records into above tables using SQL


*) Perform updation and Deletion of recoirds from above tables using SQL

2) Write a java program to perform CRUD operation for Student[rno,name,marks,subject]


table using

Statement.

3) Write a java program to perform CRUD operation for Student[rno,name,marks,subject]


table using

PreparedStatement.

4) Write a java program to show meta data information about the ResultSet generated by
running "select * from Student" query on the above Student table.

5) Write a java program to perform CRUD operation for


Employee[empid,emp_name,emp_dept,emp_salary] table using PreparedStatement. Make
sure to use Updatable and Scrollable ResultSet to perform the operations.

Week 3 :

1) Write a java servlet program to demonstrate Life Cycle of Servlet.

2) Write a java servlet program to do following :

1) Take date of birth from user on HTML form (form action -> "getdata" , method ->
"get")

2) This action must map to ShowAge servlet


3) On ShowAge servlet display current age of user in years

3) Write a java servlet program to do following :

1) Take 2 numbers from user on HTML form and choice of action using 3 radiobuttons
with choice as "ADD" , "SUBTRACT" , "MULTIPLY" (form action -> "takeinput")

2) This action must map to Decide servlet

3) There should be 3 Servlets : AddServlet , SubtractServlet , MultiplyServlet

4) On Decide servlet check which choice has been done by the user and depending on
the choice redirect the user to corresponding servlet and display the result of the operation.

4) Write a java servlet program to do following :

1) Take name from user on HTML form and choice of favorite color using 3
radiobuttons with choice as "RED" , "YELLOW" , "BLUE" (form action -> "takecolors")

2) This action must map to SetCooky servlet

3) Store username and selected color inside separate cookies on SetCooky servlet

4) There should another servlet named as GetCooky which will retrieve the cookies
and display data present in them on screen.
5) Write a java servlet program to do following :

1) Take userid and password from user on HTML form (form action -> "checkuser")

2) This action must map to ValidateUser servlet

3) Run query on database table (User) to check whether the entered userid and
password is correct

4) If correct the user should be forwarded to ProfileServlet.

5) userid should be saved in the session , the saved userid should be displayed on
ProfileServlet

6) there should be logout link to end user's session.

Week 4 :

1) Write a JSP program to do following :

1) Take date of birth from user on HTML form (form action -> "getdata" , method ->
"get")

2) This action must map to ShowAge.jsp

3) On ShowAge.jsp display current age of user in years


2) Write a JSP program to do following :

1) Take 2 numbers from user on HTML form and choice of action using 3 radiobuttons
with choice as "ADD" , "SUBTRACT" , "MULTIPLY" (form action -> "takeinput")

2) This action must map to Decide.jsp

3) There should be 3 JSP pages : Add.jsp , Subtract.jsp , Multiply.jsp

4) On Decide.jsp check which choice has been done by the user and depending on the
choice forward the user to corresponding JSP page and display the result of the operation.
(Use jsp:forward)

3) Write a JSP program to do following :

1) Take userid and password from user on HTML form (form action -> "checkuser")

2) This action must map to ValidateUser.jsp

3) Run query on database table (User) to check whether the entered userid and
password is correct

4) If yes the user should be forwarded to Profile.jsp.


5) userid should be saved in the session , the saved userid should be displayed on
Profile.jsp

6) there should be logout link to end user's session.

4) Write a JSP program to do the same thing specified in above question using MVC pattern.
(Bean class, jsp:useBean , session object must be used). After logout when user clicks on
BACK button of the web browser , user should not be shown the Profile page again.

5) Write a JSP program to do following :

1) Take user's email-id , name , password , profile photo from user in a HTML
registration form.

2) The profile photo should be saved to specific location on the web server (File
Uploading)

3) Rest of the user's information should be saved to a database table.

4) the path of the location where the profile photo has been saved must also be
saved to the database table along with the file name.

6) In above program , implement a Filter to count how many users did try to register to the
website.

7) Write a JSP Program to connect to following URL and get the json from it :
https://reqres.in/api/users?page=2

Parse the json , find out following and display it in html table :

page , total_pages , each user's first name and avatar

Week 5 :

1) Achieve following using struts framework :

1) Take userid and password from user on HTML form (form action -> "checkuser")

2) Run query on database table (User) to check whether the entered userid and
password is correct

3) If yes the user should be forwarded to Profile.jsp else to Error.jsp

4) userid should be saved in the session , the saved userid should be displayed on
Profile.jsp

5) there should be logout link to end user's session.

6) Use of ModelDriven should be there


7) Use Preparable to count how many users tried to login.

2) Achieve following using struts framework :

1) Take user's email-id , name , password , profile photo from user in a HTML
registration form.

2) The profile photo should be saved to specific location on the web server (File
Uploading)

3) Rest of the user's information should be saved to a database table.

4) the path of the location where the profile photo has been saved must also be
saved to the database table along with the file name.

You might also like