33% found this document useful (3 votes)
793 views

Core Java Assignments

This document outlines a multi-day programming assignment involving various Java concepts: 1. Day 1 involves command line argument processing, array processing, and menu-driven input/output. 2. Day 2 focuses on object-oriented concepts like classes, objects, methods and memory representation, as well as basic I/O. 3. Later days cover inheritance, exceptions, collections, generics, I/O, multi-threading and synchronization, JDBC, and networking.

Uploaded by

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

Core Java Assignments

This document outlines a multi-day programming assignment involving various Java concepts: 1. Day 1 involves command line argument processing, array processing, and menu-driven input/output. 2. Day 2 focuses on object-oriented concepts like classes, objects, methods and memory representation, as well as basic I/O. 3. Later days cover inheritance, exceptions, collections, generics, I/O, multi-threading and synchronization, JDBC, and networking.

Uploaded by

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

Day 1

1. Accept 2 numbers as command line arguments from user. If user supplies less t
han 2 arguments supply error message & terminate. .If all correct, compute avara
ge & display the same.
2. Accept any no of arguments from user as command line args.Display these argum
ents in reverse manner.
Day 2
3. Display food menu to user. User will select items from menu along with the qu
antity. (eg 1. Dosa 2. Samosa .......10 . Generate Bill ) When user enters 'Gene
rate Bill' option, display total bill & exit.
2.1.Consider the following. What will happen? MUST understand with memory diagra
ms.
class Tank {
private int level;
Tank(int l)
{
level=l;
}
public void setLevel(int level1)
{
level=level1;
}
public int getLevel()
{
return level;
}
}
public class Assignment {
public static void main(String[] args) {
Tank t1 = new Tank(10);
Tank t2 = new Tank(20);
s.o.p("1: t1.level: " + t1.getLevel() +
", t2.level: " + t2.getLevel());
t1 = t2;
s.o.p("2: t1.level: " + t1.getLevel() +
", t2.level: " + t2.getLevel());
t1.setLevel(27);
s.o.p("3: t1.level: " + t1.getLevel() +
", t2.level: " + t2.getLevel());
t2.setLevel(t1.getLevel()+10);
s.o.p("4: t1.level: " + t1.getLevel() +
", t2.level: " + t2.getLevel());
}
}
2. Create Java Application for the following .
Create Point class Point2D in package "geom" : for representing a point in x-y
co-ordinate system.
2.1Create a parameterized constructor to accept x & y co-ords.
Add show method to Point2D class : to return the x & y coords .(public String s
how())
2.2 Add isEqual method to Point2D class : boolean returning method : must ret. t

rue if both points are having same x,y co-ords or false otherwise. :
2.3 Add a method to Point2D class -- to create and return new point having given
x & y offset.
(eg Point createNewPoint(int xOffset,int yOffset))
2.4 Write TestPoint class with a main method in the separate package "tester"
2.5 Create 2 points by taking data from user. Use show method to display the coords of 2 points.
2.6 Use isEqual method : to chk the equality of 2 points.
2.7 Accept x offset & y offset from user & call createNewPoint method.Display x,
y co-ords of new point.
2.8 Create TestPoints class with main method.
Prompt user for --no of points to be created.
Create suitable array & store points.
Display all points.
Display the value of largest x-coord & y-coord.

Day 3
1. Complete all earlier assignments & revise
method overloading vs method overriding
2.
Apply inheritance & polymorphism to organization scenario
Create Emp based org structure in package com.app.dmc
---having classes Emp , Mgr and Worker
Emp state--- id(primary key-unique), name, deptId , basic
Behaviour --- get emp details --by overriding toString
Mgr state ---id,name,basic,dept,perfBonus
Behaviour ----get mgr details, compute net salary (formula: basic+perfBonus)
& getter for performance bonus.
Worker state ---id,name,basic,dept, hoursWorked,hourlyRate
Behaviour--- get worker details, compute net salary (formula: = basic+(hrs*rate
)
getter hrlyRate of the worker
Design classes based on above info.
Create a TestOrg class in tester package to create org structure having 2 manag
ers & 2 workers.
Display all employee details & net salary , from single for-each loop.
Day 4
1.Create Java application for fixed stack & growable stack of employees function
ality.
1.1 Create Employee class -- id,name, constructor,toString
1.2 Stack interface -- push & pop functionality for Emp refs.
1.3 Create implementation class -- FixedStack
1.4 Create implementation class -- GrowableStack
1.5

From tester class --- display Menu


1 -- Choose Fixed Stack
2 -- Choose Growable Stack
Accept following options only after initial selection.
3 -- Push data
4 --- Pop data
5 -- Exit
Day 5
1.
Apply exception handling to Account scenario.
1.0 Create Custom Exception class AccountHandlingException
1.1 Create Account class in bank package.
1. data members --- acct ID,customerName,type,balance
2. Add Account class constructor.
Add methods 1. withdraw(amount) -- in case of insufficient funds , raise custom excs.
2. deposit(amount)
3. transfer funds (Account dest, double amount) --in case of insufficient funds
, raise custom excs.
4. toString
1.2 Create AccountValidation class
Validation Rules(added via static methods)
1. Account balance > min balance(declare constant MIN_BALANCE)
2. valid account types -- saving,current,fd.
3. Customer name must be min 5 chars & max 10 chars long.
If rules are not satisfied , raise custom exception.
Do not handle exceptions in AccountValidation class , BUT handle them in Tester
in centralized manner.
3. Create a TestAccount class in "tester" package.
Using scanner -- accept a/c info --in case of success --display a/c summary else
--via exc -- show err mesg to customer
(using catch & getMessage)
Test Withdraw,Deposit,Funds transfer
Day 6
0. Complete pending work.
1. Revise & complete testing of String class API
2. Add overriding form of equals method to Account class(MUST use @Override ann
otation)
Treat 2 accounts same if & only if --account id & customer name is same.
3. Write TestEquals class .Create 2 account objects & test the equals method.
Day 7
1. Modify Account class to add account creation date field.
validation rules -- Account must be created in the current year
(Add this rule in AccountValidation class)

Test this from Tester.


2. Revise quickly code samples of wrappers & non-generic code.
3. Solve code samples(for wrappers & method overriding atleast)
4. MUST go through , all ArrayList based code examples from day7\lists
Day 8
Objective --- Create simple List(ArrayList) of Account & test complete API
1.1
Create Empty Arraylist of Accounts
1.2 Accept a/c info from user till user types "stop" & populate AL.
1.2.1 -- Display AL content using for-each
----------------Account equality --id & type
Add some account data in fixed(hard coded) manner
1.3 Accept account id,type & display summary or error mesg
1.4 Accept src id & type , dest id & type & funds transfer.
--------------------1.5 Accept acct id n type & remove a/c -Must use public boolean remove(Object o)
1.6
I/P
1.7
1.8

Apply interest on all saving a/cs


rate of interest
Sort accounts as per asc a/c ids. -- use natural ordering
Sort accounts as per desc a/c ids. --use custom ordering

2.0 Sort a/cs as per bal --use custom ordering


Day 9
Create a BookShop using suitable data structure.
Book -- title,author,price,publishDate
Display available books to Users.Then supply following options
1. Add Book to The Cart
I/P : Book Title
2. Remove Book From the Cart
I/P : Book Title
3. Show Cart Contents
4. Check out
Should display Total cart value & titles of the books purchased by the user.
& terminate.
Day 10
0. Write a java application for
1. Store Account info in suitable collection
2. Sort account info as per creation date.
3. Before exiting from appln --- store acct details in a text file in a buffered
manner.(different account records should appear on separate lines)
4. If time permits
restore account information from text file into suitable collection.
Ask user for acct no & display a/c summary or error message.
1. Accept strings from user till user enters "exit".
Display the word having highest no of repeatations.
2. Revise I/O overview & solve.
Create a text file containing numbers(space separated).

Write java application to display highest & lowest.


(Hint : Collection & I/O)
Day 11
Customer sign-in & sign-up utility
0.Address ---city,country,zipCode,constr,toString
1. Customer -- email(PK),password,dob,regAmount,address(city,country,zipCode)
Customer ---HAS A --Address
constructor,setter for address, toString,readDat,writeData
2.IOUtils
storeData -- DOS---BOS--FOS-bin file
restoreData ---DIS--BIS--FIS--bin file
3. RegisterCustomer --- accept cust data from user(scanner), populate it in a su
itable collection.
At the end of application --- storeData
4. ValidateCustomer
restoreData inot suitable colleciton
Using scanner , prompt user for --email & password
If success --display user details
or exc --- err mesg
Day 12
1. From earlier assignment , replace Data I/O streams by Object streams.
0. Make Customer & Address -- non -- serializable
1. Make Customer & Address -- serializable
2. Make Customer --Serializable & Address -- non-serializable
Upon observing error --fix it by using "transient" keyword.
2. Take existing Emp class(having id,name,salary)
Treat 2 employees same iff --their id & name is same.
Accordingly modify hashcode & equals .
Add emps to HashSet & check its behaviour.
Day 16
1. Complete single bouncing ball assignment
2. Solve code samples from <test_synchro> to differentiate between static & non
static synchronized methods.
3. Refer to <no_itc> & understand need of inter thread communication.
4. Understand problems in <itc_with_sleep> & <itc_with_wait> & then solve <itc_w
ith_wait_notify>
5. Solve <thrd_safe_coll>
6 Read Object class API
wait,notify & notifyAll
Day 20
1. Revise JDBC API for --Statement,PreparedStatement,CallableStatement.
2. Create standalone JDBC application for Student Utility --using layers --To di
splay all course names in JComboBox & display student details of the selected co
urse.
Tester,DAO,DTO & DB .
(Hint : can take readymade DB tables)
3. If time permits, split step 2 in 2 parts
3.1 TCP client --having GUI front end
3.2 TCP Server -- having DB connectivity.

You might also like