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

Java Lab Lesson Plan Final-2025

The document is a Java Programming Lab Manual for the School of Computer Engineering at KIIT Deemed to be University for the Spring 2024-25 semester. It outlines the course structure, including the instructor's details, course outcomes, and a detailed lesson plan with various lab experiments focusing on Java programming concepts such as object-oriented programming, inheritance, exception handling, and file handling. Each lab includes specific programming tasks aimed at developing practical skills in Java.

Uploaded by

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

Java Lab Lesson Plan Final-2025

The document is a Java Programming Lab Manual for the School of Computer Engineering at KIIT Deemed to be University for the Spring 2024-25 semester. It outlines the course structure, including the instructor's details, course outcomes, and a detailed lesson plan with various lab experiments focusing on Java programming concepts such as object-oriented programming, inheritance, exception handling, and file handling. Each lab includes specific programming tasks aimed at developing practical skills in Java.

Uploaded by

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

CS29004 Java Programming Lab Manual

School of Computer Engineering

KIIT Deemed to be University

Java Programming Laboratory Lesson Plan

Spring 2024-25 (4th Semester)

Discipline : CSE

Course name and Code : Java Programming Laboratory(CS29004)

L-T-P-Cr : 0-0-2-1

Instructor Name : Mr. Pradeep Kandula, Email: pkandulafcs@kiit.ac.in

Instructor Chamber : FB-101, Block-C, Campus-14

Technical Assistants Names: TA-1(Name, email, contact no)

TA-2(Name, email, contact no)

Course Outcomes:
Upon completion of this course, the students will be able to:

CO1: Run java programs using java compiler/IDE

CO2: Write java programs using basic object oriented programming concepts

CO3: Write programs using abstract classes interfaces and packages

CO4: Write java program using multi-threading and exception handling

CO5: Design Java application using String and I/O classes

CO6: Design GUI application using Swing and interactive application using event
handling and JDBC

School of Computer Engineering Page 1 of 18


___________________________________________________________________________________________________________________
CS29004 Java Programming Lab Manual

List of Experiments (Day wise):


Lab 1 - Course Contents:

-Writing compiling and executing a simple Java programs

List of Programs :

1. Aim of the program -Write a program to print your name, roll no, section and
branch in separate lines.

Input: Mention Name,Roll no,Section and branch


Output: Display Name
Display Roll No
Display Section
Display Branch

2. Aim of the program: Write a program to print the corresponding grade for the
given mark using if..else statement in Java

Input: Mention the grade in the program


Output: Display the Grade either O/E/A/B/C

3. Aim of the program: Write a program to print the week day for the given day no.
of the current month using switch case statement

Input: Mention the Day no in the program


Output: Display the week day(either Sunday/Monday/Tuesday/Wednesday
/Thursday/Friday/Saturday)

4. Aim of the program : Program to check a user entered number is palindrome or not

Input: Mention the number in the program


Output: display the number is Palindrome or not.

5. Aim of the program : Write a program in Java to take first name and last name from
user and print both in one line as last name followed by first name

Input: Enter first name: KIIT


Enter Second Name: UNIVERSITY
Output: UNIVERSITY KIIT

School of Computer Engineering Page 2 of 18


___________________________________________________________________________________________________________________
CS29004 Java Programming Lab Manual

Lab 2 - Course Contents: - Array in Java


- Command line arguments in Java, Scanner Class
- static modifier in Java
List of Programs :

1. Aim of the program : Find the largest among 3 user entered nos. at the command
prompt using Java

Input: Enter three number .


Output: Display the Largest Number

2. Aim of the program : Accept 10 numbers from command line and check how many
of them are even and how many are odd.

Input: Enter 10 number from keyboard


Output: Display number of even and odd number

3. Aim of the program: Program to sort the user entered list of numbers of any
size

Input: List of Numbers


Output: Display the numbers in Ascending order

4. Aim of the program: Program to find no. of objects created out of a class using
‘static’ modifier.

Input: No of objects created


Output: Display the number of objects created (e.g. no of objects=3)

5. Aim of the program: Find the no. of occurrence of each element in a user
entered list of nos.

Input: Enter list of numbers e.g.( 15 25 15 11 25 32 15 32)


Output: Occurrence of 15=3
Occurrence of 25=2
Occurrence of 11=1
Occurrence of 32=2

6. Aim of the program: Find sum of each diagonal (left & right) elements
separately of a user entered 3 X 3 matrix in Java.

Input: Enter 3X3 matrix


e.g. 673
892
129
Output: Left=24
Right=13

School of Computer Engineering Page 3 of 18


___________________________________________________________________________________________________________________
CS29004 Java Programming Lab Manual

Lab 3 - Course Contents: -class and objects in Java


-method overloading in Java
-constructor overloading in Java
List of Programs :

1. Aim of the program :Write a class file – box with three data members(length,
width, height) and a method volume() . Also implement the application class Demo
where an object of the box class is created with user entered dimensions and
volume is printed.

Input: length,width and height.


Output: Volume

2. Aim of the program : Write a program in Java to create a class Rectangle having data
members length and breadth and three methods called read, calculate and display to read
the values of length and breadth, calculate the area and perimeter of the rectangle and
display the result respectively.

Create a class named


'Rectangle' with two data
members 'length' and 'breadth'
and
two methods to print the area
and perimeter of the rectangle
respectively.
Its constructor having
parameters for length and
breadth is used to initialize
length
and breadth of the rectangle.
School of Computer Engineering Page 4 of 18
___________________________________________________________________________________________________________________
CS29004 Java Programming Lab Manual

Create a class named


'Rectangle' with two data
members 'length' and 'breadth'
and
two methods to print the area
and perimeter of the rectangle
respectively.
Its constructor having
parameters for length and
breadth is used to initialize
length
and breadth of the rectangle.
Input: Mention length and breadth
Output: Display Area of Rectangle and Perimeter of rectangle.

3. Aim of the program : Write a program in java to input and display the details of n
number of students having roll, name and cgpa as data members. Also display the
name of the student having lowest cgpa.

Input: Enter Roll No, Name and cgpa of ‘n’ number of students.
Output: Display the details of ‘n’ number of students. Also display the
name of student with lowest cgpa

4. Aim of the program : Write a program to overload subtract method with various
parameters in a class in Java. Write the driver class to use the different subtract
methods using object.

Input: Mention various subtract method having different parameters.


Output: Subtract method will display the result accordingly

School of Computer Engineering Page 5 of 18


___________________________________________________________________________________________________________________
CS29004 Java Programming Lab Manual

5. Aim of the program : Write a program which will overload the area () method and
display the area of a circle, triangle and square as per user choice and user entered
dimensions.

Input: Mention dimensions like radius, base, height, side


Output: Display area of circle
Display area of triangle
Display area of square

6. Aim of the program : Write a program in java using constructor overloading


concept to calculate the area of a rectangle having data member as length and
breadth. Use default constructor to initialize the value of the data member to zero and
parameterized constructor to initialize the value of data member according to the user
input.

Input: Mention the value of length and breadth


Output: Display the area of rectangle accordingly.

Lab 4 - Course Contents: - Single level inheritance in Java


-Multi-level inheritance in Java
- Method Overriding and use of final and super keyword in
java
- Dynamic Method Dispatch
List of Programs :

1. Aim of the program : A Plastic manufacturer sells plastic in different shapes like 2D
sheet and 3D box. The cost of sheet is Rs 40/ per square ft. and the cost of box is Rs 60/
per cubic ft. Implement it in Java to calculate the cost of plastic as per the dimensions
given by the user where 3D inherits from 2D.

Input: Enter dimensions


Output: Display the cost of plastic

2. Aim of the program : Illustrate the execution of constructors in multi-level


inheritance with three Java classes – plate(length, width), box(length, width, height), wood
box (length, width, height, thick) where box inherits from plate and woodbox inherits from
box class. Each class has constructor where dimensions are taken from user.

Input: Enter the dimensions


Output: Display the dimensions accordingly

3. Aim of the program : Write a program in Java having three classes Apple,
Banana and Cherry. Class Banana and Cherry are inherited from class Apple and
each class have their own member function show() . Using Dynamic Method
Dispatch concept display all the show() method of each class.

Input: Mention show function of each class.


Output: Display show function of each class accordingly.

School of Computer Engineering Page 6 of 18


___________________________________________________________________________________________________________________
CS29004 Java Programming Lab Manual

4. Aim of the program :Write a class Account containing acc_no, balance as data
members and two methods as input() for taking input from user and disp() method
to display the details. Create a subclass Person which has name and aadhar_no as
extra data members and override disp() function. Write the complete program to
take and print details of three persons.

Input: Enter details of three persons.


Output: Display details of three persons.

Lab 5 - Course Contents: – Abstract class in Java


– Interface in Java
- Package in Java
List of Programs :

1. Aim of the program -Illustrate the usage of abstract class with following Java
classes –
 An abstract class ‘student’ with two data members roll no, reg no, a method getinput()
and an abstract method course()
 A subclass ‘kiitian’ with course() method implementation
Write the driver class to print the all details of a kiitian object.

Input - Rollno - 2205180


Registration no - 1234567890
Output -Rollno - 2205180
Registration no - 1234567890
Course - B.Tech. (Computer Science & Engg)

2. Aim of the program -Define an interface Motor with a data member –capacity and
two methods such as run() and consume(). Define a Java class ‘Washing machine’
which implements this interface and write the code to check the value of the interface
data member thru an object of the class.
Input - mentioned in the program
Output - Capacity of the motor is -----

3. Aim of the program -Define an interface with three methods – earnings(),


deductions() and bonus() and define a Java class ‘Manager’ which uses this interface
without implementing bonus() method. Also define another Java class ‘Substaff’ which
extends from ‘Manager’ class and implements bonus() method. Write the complete
program to find out earnings, deduction and bonus of a substaff with basic salary
amount entered by the user as per the following guidelines –
earnings basic + DA (80% of basic) + HRA (15% of basic)
School of Computer Engineering Page 7 of 18
___________________________________________________________________________________________________________________
CS29004 Java Programming Lab Manual

deduction PF 12% of basic


bonus 50% of basic
Input -Basic salary - 50000
Output -Earnings - 97500
Deduction -6000
Bonus - 25000

4. Aim of the program - Define an interface Emploee with a method getDetails() to get
emplyee details as Empid and Ename. Also define a derived interface Manager with a
method getDeptDetails() to get department details such as Deptid and
Deptname.Then define a class Head which implements Manager interface and also
prints all details of the employee. Write the complete program to display all details of
one head of the department.

Input - Enter employee id - 123


Enter employee name - Sidharth Ambani
Enter department id - 06
Enter department name -Marketing
Output - Employee id - 123
Employee name - Sidharth Ambani
Department id - 06
Department name -Marketing

5. Aim of the program - Define two packages as – General and Marketing. In General
package define a class ‘employee’ with data members as empid(protected),
ename(private) and a public method as earnings() which calculate total earnings as

earnings basic + DA (80% of basic) + HRA (15% of basic)

In Marketing package define a class ‘sales’ which is extending from ‘employee’ class
and has a method tallowance() which calculates Travelling Allowance as 5% of total
earning. Write the programs to find out total earning of a sales person for the given
basic salary amount and print along with the emp id.
Input: Enter the employee id and emploee name 123 Amit
Enter the basic salary 1000
Output: The emp id of the employee is 123
The total earning is 1950.0

Lab 6 - Course Contents: - Exception handling in Java


- User defined exception in Java
List of Programs :

1. Aim of the program - Write a Java program to generate an


ArrayIndexOutofBoundsException and handle it using catch statement.

Input: Enter the numbers -Example: 1 2 3 4 5 ( Suppose array size is 4 )


Output: Exception in thread “main”
java.lang.ArrayIndexOutOfBoundsException:4
School of Computer Engineering Page 8 of 18
___________________________________________________________________________________________________________________
CS29004 Java Programming Lab Manual

2. Aim of the program- Write a Java program to handle an ArithmeticException


using try, catch, and finally block.

Input: Operand values for division operation mentioned in the program


Output: ArithmeticException caught by try-catch-finally block

3. Aim of the program- Write a Java class which has a method called
ProcessInput(). This method checks the number entered by the user. If the
entered number is negative then throw an user defined exception called
NegativeNumberException, otherwise it displays the double value of the
entered number.

Input: Enter a number 4


Output: Double value: 8
Input: Enter a number -4
Output: Caught the exception
Exception occurred: NegativeNumberException: number should be
positive

4. Aim of the Program: Write a program to create user defined exceptions called
HrsException, MinException and SecException. Create a class Time which
contains data members hours, minutes, seconds and a method to take a time
from user which throws the user defined exceptions if hours (>24
&<0),minutes(>60 &<0),seconds(>60 &<0).

Input: Enter hours: 4


Enter minutes: 54
Enter seconds: 34
Output: Correct Time-> 4:54:34

Input: Enter hours: 30


Enter minutes: 65
Enter seconds: 65
Output: Caught the exception
Exception occurred: InvalidHourException:hour is not greater than
24
Exception occurred: InvalidMinuteException:hour is not greater
than 60
Exception occurred: InvalidSecondException:hour is not greater
than 60

5. Aim of the Program: Create an user defined exception named


CheckArgument to check the number of arguments passed through command
line. If the number of arguments is less than four then throw the Check
Argument exception, else print the addition of squares of all the four elements.
School of Computer Engineering Page 9 of 18
___________________________________________________________________________________________________________________
CS29004 Java Programming Lab Manual

Input: 4 3 2 1
Output : 30
Input: 4 3 2
Output : Exception occurred - CheckArgument

Lab 7 - Course Contents: - String handling in Java

- File Handling in Java

List of Programs :
1. Aim of the program -Write a program to perform following operations on user
entered strings and a character –
i) Change the case of the string
ii) Reverse the string
iii) Compare two strings
iv) Insert one string into another string
v) Convert the string to upper case and lower case
vi) Check whether the character is present in the string and at which position
vii) Check whether the string is palindrome or not.
viii) Check the number of word, vowel and consonant in the string

Input: Enter a String : amit


Output: The string after changing the case is AMIT
The string after reversing is tima

Input: Enter the second string for comparision : kumar


Output: The difference between ASCII value is 10

Input: Enter the string to be inserted into first string : thakur


Output: The string after insertion is : amit thakur

Input: Enter a String : Amit


Output: Uppercase: AMIT
Lowercase: amit

Input: Enter a String :Amitkumar


Enter a character : m
Output: Position of entered character: 2

Input: Enter a String : Amitkumar


Enter a character : Y
Output: Entered character is not present

Input: Enter a String : madam


School of Computer Engineering Page 10 of 18
___________________________________________________________________________________________________________________
CS29004 Java Programming Lab Manual

Output: Entered string is palindrome

Input: Enter a String : muscle


Output: Entered string is not a palindrome

Input: Enter a String : Ram is going to school


Output: No. of words: 5
No. of vowels: 7
No. of consonants: 11

2. Aim of the program - Write a java program which will accept students details
like Student RollNo, Name, Subject, Marks from the keyboard using scanner
class, stored the same in a file. Again open the file, read the content and
display all.

Input: Enter student details - Rollno, name, subject, marks


Enter the name of existing file to which student details will be written.
Output: Display the content of existing file

3. Aim of the program - Write a program in Java to copy the content of a given
file to another user entered file using character stream (using File Reader and
FileWriter Classes) and byte Stream (using FileInputStream and
FileOutputStream Class).

Input: Enter the source file name - sourcefile.txt (Assume Input file
exists in the system)
Enter the destination file name - destinationfile.txt
Output: File Copied

4. Aim of the program -Write a java program to compare two binary files, printing
the first byte position where they differ.

Input: Specify two binary files in the program (Assume two files are exist in
the system)
Output: Two files are equal
Input: Specify two binary files in the program
Output: Two files are not equal: byte position at which two files differ is 30

5. Aim of the program -Write a java program that displays the number of
characters, no. of lines and no. of words present in a text file whose name is
given by the user.

Input: Name of the file - filename


School of Computer Engineering Page 11 of 18
___________________________________________________________________________________________________________________
CS29004 Java Programming Lab Manual

Output: No. of characters - A,


No .of lines - B
No . of words - C

Lab 8 - Course Contents: - Multi-threading in Java

List of Programs :
1. Aim of the program - Write a program in Java using multi-threading which will
display a counter value within a specified range with a gap of 5 milliseconds after
setting it’s name as given by the user.
Input : Name of the thread - First
Lower range of counter - 10
Upper range of counter - 15
Output : Thread - First
Counter - 10 11 12 13 14 15

2. Aim of the program -Write a program in java which will display the working of two
threads in synchronization.
Input:
Output:

3. Aim of the program -Design a Stop Watch using event handling and multi-
threading in Java.

School of Computer Engineering Page 12 of 18


___________________________________________________________________________________________________________________
CS29004 Java Programming Lab Manual

Practice Program Sets:-

1. Aim of the program - Design a swing application using event and multithreading
which will display multiple images one after another moving in a square shape with a gap
of 10 millisecond. At the same time, four messages like - " Welcome "," Enjoy "," Thanks ","
Visit Again " will also be displayed one after another on the same page.

Output: Animation of images

Lab 9- Course Contents: – Java Database Connectivity

List of Programs :
1. Aim of the program -Write a java program which will display all the records from
the student table.
Input : Table name mentioned in the program
Output :
2205123 rakesh yadav 76

2. Aim of the program - 2205230 sanjiv kumar 82 Write a java


program which will display a particular
record from the student 2206345 pranab dutta 73 table on the
basis of RollNo supplied 2206242 asish mukherjee 78
from the
keyboard.
Input : 2205542 suman singh 85 Rollno
(2205542)
Output : 2205542 suman singh 85

3. Aim of the program - Write a java program which will insert a record, update and
delete a particular record in the student table.
Input : Enter rollno to be inserted : 2205650
Enter name : Aditya Bajaj
Enter marks : 93
Output : 1 record inserted

School of Computer Engineering Page 13 of 18


___________________________________________________________________________________________________________________
CS29004 Java Programming Lab Manual

4. Aim of the program -Write a java program which will display all the records from
the student table along with the column heading.
Input :Table name mentioned in the program

Output : Roll no Name Marks

2205123 rakesh yadav 76

2205230 sanjiv kumar 82

2206345 pranab dutta 73

2206242 asish mukherjee 78


5. Aim of the program -Design an
interface as shown below 2205542 suman singh 85 using
Frame and Swing in Java

Here the user will write a query in the text field and then click on the execute query
button. The output of the query will be displayed on another hidden text area.
Input : select mark from student where rollno= 2205230
Output : 82

Practice Program Sets:-

Aim of the program -Design an interface as shown below using Frame and Swing in Java
.

School of Computer Engineering Page 14 of 18


___________________________________________________________________________________________________________________
CS29004 Java Programming Lab Manual

The user will fill up the details and after clicking on the insert button, the data will be
inserted in the table. Similarly Update button will update the record based on the Roll No
and in the same way delete button will delete the corresponding record from the table.
Input : Rollno - 2205423
Name - Manish Malhotra
Marks - 84
Output : On clicking Insert button - one record inserted
On clicking Update button - one record updated
On clicking Delete button - one record deleted

Lab 10 - Course Contents: – GUI Programming using Swing in Java


– Event Handling in Java

List of Programs :
1. Aim of the program -Design a registration form using Swing with following
components on it – Label, Textbox, Text area, Checkbox, Radio button and Button,
Image.

2. Aim of the program -Write a GUI program in Java with three Labels – Enter the First
Number, Enter the Second Number, Result, and three text fields for - first number,
second number and result and four buttons - Add, Sub, multiply and reset as shown
below. On clicking of any of these buttons, the corresponding operation should be
performed with input1 and input2 and the result should be displayed in the result box.

Input: First and second number


Output: Appropriate result will be displayed in the result text field

3. Aim of the program -Implement a GUI application which consists of one List Box
and one button. The list box will have four different color names. When the user will
select a color from the list box and click on the button, the panel color will be
changed to that color.

Input: Select any color from the list box


Output: Panel background color will be changed accordingly

School of Computer Engineering Page 15 of 18


___________________________________________________________________________________________________________________
CS29004 Java Programming Lab Manual

4. Aim of the program -Design a GUI application which consists of three Label
named as Red, Green and blue, three combo boxes which will consist the value from
0 to 255 and one button named as show output. The user will select different values
from three combo boxes. When the user clicks on the button, the panel background
will be changed accordingly as per the value passed in RGB format.

Input: select three color value(0-255) from 3 different combo box.


Output: The panel color will be changed accordingly

Practice Program Sets:-

1. Aim of the program -Design a GUI Calculator as shown below using frame and
action event in Java.

Input: Any two number with one operator and then click on = button.
Output: Appropriate result will be displayed.

School of Computer Engineering Page 16 of 18


___________________________________________________________________________________________________________________
CS29004 Java Programming Lab Manual

2. Aim of the program -Design a GUI application as shown below which consists of
two text fields and various buttons for String operations. On clicking any of the
button, the corresponding operation will be performed on the entered string in the
first text field and the resultant string will be displayed in the second text field.

Input: Any string in the fist text field and click on any button.
Output: Modified string in the second field

Grading Policies:
 Continuous Evaluation components
Internal Evaluation (Continuous Evaluation over the semester which includes
Quiz/Viva/Lab Record/Lab performance/Attendance etc.) : 60 Marks

 End semester evaluation


End-Term Evaluation (Sessional Exam) : 40 Marks

Reference Materials:-
Reference Book:

1. Java-The Complete Reference, Herbert Schildt, 10th Edition, McGraw Hill


Education, 2014
2. Introduction to JAVA Programming, Y.Daniel Liang, 10th Edition, Pearson
Education, 2007
3. Java Programming – for Core and Advanced Users, Sagayaraj, Denis, Karthik
and Gajalakshmi, Universities Press.
4. Java - One Step Ahead, by Anita Seth and B L Juneja, published by Oxford
University Press

School of Computer Engineering Page 17 of 18


___________________________________________________________________________________________________________________
CS29004 Java Programming Lab Manual

School of Computer Engineering Page 18 of 18


___________________________________________________________________________________________________________________

You might also like