0% found this document useful (0 votes)
4 views18 pages

Java Workbook

The document is a Java workbook from Bhilai Institute of Technology, detailing various lab experiments for the Electronics and Computer Science branch. Each lab focuses on different Java programming concepts, including control structures, multilevel inheritance, multithreading, file handling, and GUI components. The workbook includes objectives, algorithms, and program codes for each experiment.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views18 pages

Java Workbook

The document is a Java workbook from Bhilai Institute of Technology, detailing various lab experiments for the Electronics and Computer Science branch. Each lab focuses on different Java programming concepts, including control structures, multilevel inheritance, multithreading, file handling, and GUI components. The workbook includes objectives, algorithms, and program codes for each experiment.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java Workbook Bhilai Institute of Technology, Durg

Electronics and Computer Science Branch


INDEX PAGE

Student’s Name Branch & Semester University Roll No.

Exp Aim of Experiment Date Page Sign


1 Control and looping structures in Java
2 Read N elements in array and search ele-
ment
3 Multilevel inheritance using parameter-
ized constructors
4 Customized checked exception for values
< 20 or > 50
5 Multithreading using two threads (ran-
dom and sequential)
6 Object level lock and class level lock in
threads
7 Producer-consumer problem using multi-
threading
8 Count files and folders using File class
9 Count characters, words, symbols and
numbers in file
10 Dialog class popup message on button
click
11 AWT/Swing textbox, button and list ex-
ample
12 Customer database add, delete, search
and edit
13 Demonstrate ServerSocket and Socket
14 Read file words and store in Vector
15 Generic class and Generic method in Java

Dr. Chaitali Choudhary


Assistant Professor

Object Oriented Programming with Java Lab


Java Workbook Bhilai Institute of Technology, Durg

Lab 1
Aim: Write a program in Java to demonstrate the use of control structures and looping
structures.
Objective: Write a Java program that demonstrates the use of control structures and
looping statements. The program should perform the following tasks:

1. Accept an integer input from the user and determine whether the number is positive,
negative, or zero using if–else statements.

2. Accept a number between 1 and 7 from the user and display the corresponding day of the
week using a switch statement.

3. Use a for loop to display numbers from 1 to 5.

4. Use a while loop to display numbers from 1 to 5.

5. Use a do–while loop to display numbers from 1 to 5.

Program code:

Object Oriented Programming with Java Lab


Java Workbook Bhilai Institute of Technology, Durg

Lab 2
Objective: Write a Java program to read N elements into an array and search an element.
Algorithm:

1. Read number of elements N.

2. Store elements in array.

3. Input search key.

4. Traverse array.

5. If found display position.

Program code:

Object Oriented Programming with Java Lab


Java Workbook Bhilai Institute of Technology, Durg

Lab 3
Objective: Write a Java program to demonstrate multilevel inheritance using param-
eterized constructors. The program should implement the following classes:

1. Class Person (Base Class)

• Data Members:
– String name
– int age
• Constructor:
– Person(String name, int age) – initializes the data members.
• Method:
– void displayPerson() – displays the person’s name and age.

2. Class Employee (Derived Class of Person)

• Data Members:
– int empId
– double salary
• Constructor:
– Employee(String name, int age, int empId, double salary)
• Method:
– void displayEmployee() – displays employee ID and salary.

3. Class Manager (Derived Class of Employee)

• Data Member:
– String department
• Constructor:
– Manager(String name, int age, int empId, double salary, String department)
• Method:
– void displayManager() – displays department details.

4. Main Class: MultilevelInheritanceDemo

• Create an object of the Manager class.


• Pass values using the parameterized constructor.
• Call the methods to display all inherited details.

Object Oriented Programming with Java Lab


Java Workbook Bhilai Institute of Technology, Durg

Program code:

Object Oriented Programming with Java Lab


Java Workbook Bhilai Institute of Technology, Durg

Lab 4
Objective: Generate a customized checked exception when input number is less than 20 or
greater than 50.

Program code:

Object Oriented Programming with Java Lab


Java Workbook Bhilai Institute of Technology, Durg

Lab 5
Objective: Demonstrate multithreading using two threads to read the string “MULTI
THREADING IN JAVA”.

Program code:

Object Oriented Programming with Java Lab


Java Workbook Bhilai Institute of Technology, Durg

Lab 6
Aim: Demonstrate object level lock and class level lock in Java threads.

Program code:

Object Oriented Programming with Java Lab


Java Workbook Bhilai Institute of Technology, Durg

Lab 7
Aim: Implement Producer Consumer problem using multithreading.

Program code:

Object Oriented Programming with Java Lab


Java Workbook Bhilai Institute of Technology, Durg

Lab 8
Aim: Count number of files and folders present in a directory using File class.

Program code:

Object Oriented Programming with Java Lab


Java Workbook Bhilai Institute of Technology, Durg

Lab 9
Aim: Count characters, words, special symbols and numbers in a text file.

Program code:

Object Oriented Programming with Java Lab


Java Workbook Bhilai Institute of Technology, Durg

Lab 10
Aim: Implement Dialog class to display popup welcome message when button is clicked.

Program code:

Object Oriented Programming with Java Lab


Java Workbook Bhilai Institute of Technology, Durg

Lab 11
Aim: Using AWT/Swing create textbox T1, button B1 and list L1 to add text.

Program code:

Object Oriented Programming with Java Lab


Java Workbook Bhilai Institute of Technology, Durg

Lab 12
Aim: Perform add, delete, search and edit operations on Customer database.

Program code:

Object Oriented Programming with Java Lab


Java Workbook Bhilai Institute of Technology, Durg

Lab 13
Aim: Demonstrate ServerSocket and Socket communication.

Program code:

Object Oriented Programming with Java Lab


Java Workbook Bhilai Institute of Technology, Durg

Lab 14
Aim: Read words from text file and store them in a Vector.

Program code:

Object Oriented Programming with Java Lab


Java Workbook Bhilai Institute of Technology, Durg

Lab 15
Aim: Demonstrate Generic class and Generic method in Java.

Program code:

Object Oriented Programming with Java Lab


Java Workbook Bhilai Institute of Technology, Durg

Object Oriented Programming with Java Lab

You might also like