Visit For More : www.LearnEngineering.
in
CS8383 –OBJECT ORIENTED LABORATORY
SYLLABUS
COURSE OBJECTIVES
To build software development skills using java programming for real-world applications.
To understand and apply the concepts of classes, packages, interfaces, arraylist, exception handling
and file processing.
n
To develop applications using generic programming and event handling.
g.i
LIST OF EXPERIMENTS:
rin
1. Develop a Java application to generate Electricity bill. Create a class with the following members:
ee
Consumer no., consumer name, previous month reading, current month reading, type of EB connection
(i.e domestic or commercial). Compute the bill amount using the
gin
following tariff.
If the type of the EB connection is domestic, calculate the amount to be paid as follows:
En
First 100 units - Rs. 1 per unit
101-200 units - Rs. 2.50 per unit
arn
201 -500 units - Rs. 4 per unit
> 501 units - Rs. 6 per unit
Le
If the type of the EB connection is commercial, calculate the amount to be paid as follows:
w.
First 100 units - Rs. 2 per unit
101-200 units - Rs. 4.50 per unit
ww
201 -500 units - Rs. 6 per unit
> 501 units - Rs. 7 per unit
2. Develop a javaL application to implement currency converter (Dollar to INR, EURO to INR, Yen to INR
and vice versa), distance converter (meter to KM, miles to KM and vice versa) , time converter
(hours to minutes, seconds and vice versa) using packages.
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
3. Develop a java application with Employee class with Emp_name, Emp_id, Address, Mail_id, Mobile_no
as members. Inherit the classes, Programmer, Assistant Professor, Associate Professor and Professor
from employee class. Add Basic Pay (BP) as the member of all the inherited classes with 97% of BP as
DA, 10 % of BP as HRA, 12% of BP as PF, 0.1% of BP
for staff club fund. Generate pay slips for the employees with their gross and net salary.
4. Design a Java interface for ADT Stack. Implement this interface using array. Provide
necessary exception handling in both the implementations.
5. Write a program to perform string operations using ArrayList. Write functions
n
for the following
g.i
a. Append - add at end
rin
b. Insert – add at particular index
c. Search
ee
d. List all string starts with given letter
6. Write a Java Program to create an abstract class named Shape that contains two
gin
integers and an empty method named print Area(). Provide three classes named
Rectangle, Triangle and Circle such that each one of the classes extends the class
En
Shape. Each one of the classes contains only the method print Area () that prints the
area of the given shape.
arn
7. Write a Java program to implement user defined exception handling.
8. Write a Java program that reads a file name from the user, displays information about
Le
whether the file exists, whether the file is readable, or writable, the type of file and the
w.
length of the file in bytes.
9. Write a java program that implements a multi-threaded application that has three threads.
ww
First thread generates a random integer every 1 second and if the value is even, second
thread computes the square of the number and prints. If the value is odd, the third thread
will print the value of cube of the number.
10. Write a java program to find the maximum value from the given type of elements using a
generic function.
11. Design a calculator using event-driven programming paradigm of Java with the
following options.
10
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
a) Decimal manipulations
b) Scientific manipulations
12. Develop a mini project for any application using Java concepts.
n
g.i
rin
ee
gin
En
arn
Le
w.
ww
11
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
CS8383 – OBJECT ORIENTED PROGRAMMING LABORATORY
INDEX
Sl. No. Name of the Experiment Page No.
1 Electricity Bill Generation 13
2 Currency converter , Distance converter and Time converter 15
n
3 Payroll Processing 18
g.i
4 ADT Stack 19
5 String Operations 21
rin
6 Abstract Class 23
7
8
Exception Handling
File Information
ee 25
27
gin
9 Multithreading 29
10 Generic Function 31
En
11 Calculator 33
12 Mini Project – Vehicle Management System 36
arn
Le
w.
ww
12
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Ex. No.:1
ELECTRICITY BILL GENERATION
Aim:
To develop a Java application to generate Electricity bill.
Hardware Requirements:
Pentium IV with 2 GB RAM
160 GB HARD Disk
n
Monitor 1024 x 768 colour
g.i
Software Requirements:
rin
Ubentu 14.04 operating system
JDK 1.8
Procedure:
ee
gin
1. Start the program
2. Create consumer class with the following members: Consumer no., consumer name,
previous month reading, current month reading, type of EB connection (i.e domestic or
En
commercial).
arn
3.If the type of the EB connection is domestic, calculate the amount to be paid as follows:
First 100 units - Rs.1 per unit
Le
101-200 units - Rs.2.50 per unit
201 -500 units - Rs. 4 per unit
w.
> 501 units - Rs.6 per unit
4. If the type of the EB connection is commercial, calculate the amount to be paid as follows:
ww
First 100 units - Rs. 2 per unit
101-200 units - Rs. 4.50 per unit
201 -500 units - Rs. 6 per unit
> 501 units - Rs. 7 per unit
5. Print the amount
6. Stop the program
13
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Sample output:
n
g.i
rin
ee
gin
En
Result:
arn
Thus the Electricity Bill Java application was successfully executed.
Outcome:
Le
Thus the course outcome (CO1) has been attained by generating an Electricity Bill application using
w.
Java.
Applications :
ww
(1) Payroll Processing
(2) PF Calculation
14
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Ex. No.:2
Currency Converter, Distance Converter and Time Converter
Aim:
To develop a Java application to implement currency converter , distance converter and time converter
using packages.
Hardware Requirements:
n
Pentium IV with 2 GB RAM
g.i
160 GB HARD Disk
rin
Monitor 1024 x 768 colour
Software Requirements:
ee
Ubentu 14.04 operating system
gin
JDK 1.8
Procedure:
En
1. Start the program
2. Create three packages for currency converter , distance converter and time converter.
arn
3. Create corresponding code for conversion
4. Print the converted value.
Le
5. Stop the program
w.
ww
15
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Sample output:
n
g.i
rin
ee
gin
En
Result:
arn
Thus the Java application has been created for currency conversion, distance conversion and time
Le
conversion and it was successfully executed.
Outcome:
w.
Thus the course outcome (CO2) has been attained by applying the concept of packages using Java.
ww
Applications :
(1) Kilogram to gram conversion
(2) Celsius to Fahrenheit conversion
16
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Ex. No.:3
PAYROLL PROCESSING
Aim:
To develop a Java application with employee class and generate pay slips for the employees with their
gross and net salary.
Hardware Requirements:
n
Pentium IV with 2 GB RAM
g.i
160 GB HARD Disk
Monitor 1024 x 768 colour
rin
Software Requirements:
ee
Ubentu 14.04 operating system
gin
JDK 1.8
Procedure:
En
1. Start the program
arn
2. Create Employee class with Emp_name, Emp_id, Address, Mail_id, Mobile_no as
members.
3.Inherit the classes, Programmer, Assistant Professor, Associate Professor and Professor
Le
from employee class.
4.Add Basic Pay (BP) as the member of all the inherited classes with 97% of BP as DA, 10
w.
% of BP as HRA, 12% of BP as PF, 0.1% of BP for staff club fund.
ww
5. Generate pay slips for the employees with their gross and net salary.
6. Stop the program
17
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Sample output:
n
g.i
rin
ee
gin
En
Result:
arn
Thus the Java application has been created with with employee class and pay slips are generated for
the employees with their gross and net salary.
Le
Outcome:
w.
Thus the course outcome (CO1) has been attained by applying the concept of inheritance to
ww
generate Payroll Processing application using Java.
Applications:
(1) EB Bill Generation
(2) Income Tax Calculation
18
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Ex. No.:4
ADT STACK
Aim
To design a Java interface for ADT Stack using array.
Hardware Requirements:
Pentium IV with 2 GB RAM
n
160 GB HARD Disk
g.i
Monitor 1024 x 768 colour
Software Requirements:
rin
Ubentu 14.04 operating system
JDK 1.8
Procedure: ee
gin
1. Start the program
2. Define the interface.
En
3. Read the elements using array.
4. Initialize stackTop pointer as zero,
arn
5. Define and use the method Push() to insert the elements into the stack with ‘STACK
OVERFLOW’ condition.
Le
6. Define and use the method pop() to remove an element from an array with ‘STACK
UNDERFLOW’ condition
w.
7. Display the output.
ww
19
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Sample output:
n
g.i
rin
ee
gin
Result:
En
Thus the design and implementation of ADT Stack using array has successfully executed.
arn
Outcome:
Thus the course outcome (CO2) has been attained by applying the concept of array to generate
Le
ADT Stack using Java.
w.
Applications:
ww
(1) ADT Queue
(2) ADT circular queue
20
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Ex. No.:5
STRING OPERATIONS
Aim
To write a program to perform string operations using ArrayList.
Hardware Requirements:
Pentium IV with 2 GB RAM
160 GB HARD Disk
n
Monitor 1024 x 768 colour
g.i
Software Requirements:
rin
Ubentu 14.04 operating system
JDK 1.8
Procedure:
ee
gin
1. Start the program
2. Add the String as an object to List.
En
3. Get the choice from the user and do according to the choice
arn
a. Append-add at end
b. Insert-add at particular index
c. Search
Le
d. List all string starts with given letter.
3. Display the result
w.
4. Stop the program.
ww
21
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Sample output:
n
g.i
rin
ee
gin
Result:
En
Thus the implementation of string operations using array list has been successfully executed.
Outcome:
arn
Thus the course outcome (CO2) has been attained by applying the concept of arraylist for string
Le
manipulations using Java.
Applications:
w.
(1) Reverse of the String.
ww
(2) String Matching.
(3) Counting the number of vowels and consonants in a line.
22
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Ex. No.:6
ABSTRACT CLASS
Aim
To write a Java Program to create an abstract class named Shape and provide three classes named
Rectangle, Triangle and Circle such that each one of the classes extends the class Shape.
Hardware Requirements:
n
Pentium IV with 2 GB RAM
g.i
160 GB HARD Disk
Monitor 1024 x 768 colour
rin
Software Requirements:
ee
Ubentu 14.04 operating system
JDK 1.8
gin
Procedure:
En
1. Start the program
2. Define the abstract class shape.
arn
3. Define the class Rectangle with PrintArea() method that extends(makes use of) Shape.
4. Define the class Triangle with PrintArea() method that extends(makes use of) Shape.
Le
5. Define the class Circle with PrintArea() method that extends(makes use of) Shape.
6. Print the area of the Rectangle,Triangle and Circle .
w.
7.Stop the Program.
ww
23
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Sample output:
n
g.i
rin
Result:
ee
gin
Thus the design and implementation of Abstract class has been successfully executed.
En
Outcome:
arn
Thus the course outcome (CO2) has been attained by applying the concept of abstract class using
Java.
Le
Applications:
w.
(1) Volume of the Cube
(2) Length of the Cube
(3) Area of Triangle
ww
24
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Ex. No.:7
EXCEPTION HANDLING
Aim
To write a Java program to implement user defined exception handling.
Hardware Requirements:
Pentium IV with 2 GB RAM
n
160 GB HARD Disk
g.i
Monitor 1024 x 768 colour
Software Requirements:
rin
Ubentu 14.04 operating system
JDK 1.8
ee
gin
Procedure:
1. Start the program
En
2. Define the exception for getting a number from the user.
3. If the number is positive print the number as such.
arn
4. If the number is negative throw the exception to the user as ‘Number must be
positive’.
Le
5. Stop the Program.
w.
ww
25
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Sample output:
n
g.i
rin
Result:
ee
gin
Thus the user defined exception has been successfully implemented.
En
Outcome:
arn
Thus the course outcome (CO2) has been attained by applying the concept of Exception handling
for an user defined exception using Java.
Le
Applications:
w.
(1) Throwing exception for Checking the @ symbol in Email Id
(2) Throwing exception for password mismatch.
ww
26
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Ex. No.: 8
FILE INFORMATION
Aim
To write a Java program that reads a file name from the user, displays information about whether the file
exists, whether the file is readable, or writable, the type of file and the length of the file in bytes.
Hardware Requirements:
n
Pentium IV with 2 GB RAM
g.i
160 GB HARD Disk
Monitor 1024 x 768 colour
rin
Software Requirements:
Ubentu 14.04 operating system
JDK 1.8
Procedure:
ee
gin
1. Start the program
2. Read the filename from the user.
En
3. Use getName() Method to display the filename.
arn
4. Use getPath() Method to display the path of the file.
5. Use getParent() Method to display its parent’s information.
6. Use exists() Method to display whether the file exist or not
Le
7. Use isFile() and isDirectory() Methods to display whether the file is file or directory.
8.Use canRead() and canWrite) methods to display whether the file is readable or writable.
w.
9. Use lastModified() Method to display the modified information.
ww
10. Use length() method to display the size of the file.
11. Use isHiddden() Method to display whether the file is hidden or not.
27
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Sample output:
n
g.i
rin
Result:
ee
gin
Thus the information of the file has been displayed successfully using various file methods.
En
Outcome:
arn
Thus the course outcome (CO1) has been attained y file operations using Java..
Le
Applications:
w.
(1) IRCTC chart display (RAC reservation)
(2) A2B menu display
ww
28
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Ex. No.: 9
MULTITHREADING
Aim
To write a java program that implements a multi-threaded application.
Hardware Requirements:
n
g.i
Pentium IV with 2 GB RAM
160 GB HARD Disk
rin
Monitor 1024 x 768 colour
Software Requirements:
Ubentu 14.04 operating system ee
gin
JDK 1.8
Procedure:
En
1. Start the program
arn
2. Design the first thread that generates a random integer for every 1 second .
3. If the first thread value is even, design the second thread as the square of the number
Le
and then print it.
4.If the first thread value is odd, then third thread will print the value of cube of the
w.
number.
5. Stop the program.
ww
29
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Sample output:
n
g.i
rin
ee
gin
En
arn
Result:
Thus the implementation of multithreading has been done using three threads.
Le
Outcome:
w.
Thus the course outcome (CO2) has been attained by applying the concept of multithreading to
generate odd numbers and its square using Java.
ww
Applications :
(1) Multiplication Table Printing (3,5,8th table)
(2) Printing Area of the cube, square and circle
30
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Ex. No.: 10
GENERIC FUNCTION
Aim
To write a java program to find the maximum value from the given type of elements using a generic
function.
Hardware Requirements:
n
Pentium IV with 2 GB RAM
g.i
160 GB HARD Disk
Monitor 1024 x 768 colour
rin
Software Requirements:
Ubentu 14.04 operating system
JDK 1.8 ee
gin
Procedure:
En
1. Start the program
2. Define the array with the elements
arn
3. Sets the first value in the array as the current maximum
4. Find the maximum value by comparing each elements of the array
Le
5. Display the maximum value
6. Stop the program.
w.
ww
31
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Sample output:
n
g.i
rin
ee
gin
En
Result:
arn
Thus the implementation of generic function is achieved for finding the maximum value from the given
type of elements.
Le
Outcome:
w.
Thus the course outcome (CO3) has been attained by applying the concept of generic function to
ww
generate maximum value and minimum value. .
Applications:
(1) Finding even values
(2). Finding the sum of values
32
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Ex. No.: 11
CALCULATOR
Aim
To design a calculator using event-driven programming paradigm of Java for Decimal manipulations and
Scientific manipulations.
Hardware Requirements:
n
Pentium IV with 2 GB RAM
g.i
160 GB HARD Disk
Monitor 1024 x 768 colour
rin
Software Requirements:
ee
Ubentu 14.04 operating system
JDK 1.8
gin
Procedure:
En
1. Start the program
arn
2. Using the swing components design the buttons of the calculator
3. Use key events and key listener to listen the events of the calculator.
4. Do the necessary manipulations.
Le
5. Stop the program.
w.
ww
33
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Sample Output:
n
g.i
rin
ee
gin
En
arn
Le
w.
Result:
ww
Thus the implementation of generic function is achieved for finding the maximum value from the given
type of elements.
Outcome:
Thus the course outcome (CO3) has been attained by applying the concept of event handling to
design calculator using Java.
34
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Applications:
(1) Age calculator
(2) EB calculator
n
g.i
rin
ee
gin
En
arn
Le
w.
ww
35
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Ex. No.: 12
VEHICLE MANAGEMENT SYSTEM
Aim
To design a vehicle management system using Java.
Hardware Requirements:
Pentium IV with 2 GB RAM
160 GB HARD Disk
n
Monitor 1024 x 768 colour
g.i
Software Requirements:
rin
Ubentu 14.04 operating system
JDK 1.8
Notepad
Internet Explorer 4.0
ee
gin
Procedure:
1. Start the program
En
2. Using the swing components design the necessary layout
3. Add the details using JDBC(Java Data Base Connectivity).
arn
4. Get the details of vehicle number, make, Fuel type , Vehicle type ,Insurer ,Rupees per
kilometer , Cost and company from the user
Le
5. Store it in the database and do the necessary manipulations.
6. Stop the program
w.
ww
36
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
Sample output:
Admin Page
n
g.i
VEHICLE MANAGEMENT – ADMIN
rin
Vehicle Details :
ee
gin
En
arn
Le
w.
ww
Result:
Thus the design of vehicle management system using Java has been successfully executed.
Outcome:
Thus the course outcome (CO1) has been attained by generating a real world application using
Java.
37
Visit For More : www.LearnEngineering.in
Visit For More : www.LearnEngineering.in
MINIPROJECTS
1. Airline Reservation System
2. Mark sheet Preparation system
3. NAAC online application creation
4. Library Management System
n
5. Converting RGB image to Gray Image
g.i
6. Health Care System
rin
7. App development
8. Income Tax System
9. Vehicle Tracking System ee
gin
10. Ebanking System
En
arn
Le
w.
ww
38
Visit For More : www.LearnEngineering.in