DON BOSCO ARTS & SCIENCE COLLEGE
(Co-Education)
(Affiliated to University of Madras)
45, Landons Road, Kilpauk, Chennai-10
DEPARTMENT OF COMPUTER APPLICATIONS
Name of the Student : ………………………………………….
University Register No : ………………………………………….
Semester : IV
Subject : Java Programming Practical
Subject Code : 220C41
Batch : ………………………………………….
DON BOSCO ARTS & SCIENCE COLLEGE
(Co-Education)
(Affiliated to University of Madras)
45, Landons Road, Kilpauk, Chennai-10
BONAFIDE CERTIFICATE
This is to certify that Mr./Ms. …………………………………………………..,
bearing Register Number ………………………………., is a bonafide student of
………………………………………………………………………College, enrolled in the
………………………………… Programme (Semester ……. ) during the academic year
2025 – 2026.
This laboratory record entitled “Java Programming Practical” is an authentic and original
record of the practical work carried out by the student in accordance with the prescribed
university syllabus. The record has been duly examined, evaluated, and found to be satisfactory
in all respects.
Subject-Handler Head of the Department
This laboratory record is hereby submitted for the practical examination
conducted in ………………………………………………….……………. of the year 2026
at ………………………………………………………………………………………………
Internal Examiner External Examiner
Lab Journal
“Ideas are easy; making a computer follow them is hard. If your code doesn’t work, you don’t truly
understand your own idea… so try again, champ.”
INDEX
[Link]. Date Title Page Marks Sign
No. (10)
1. Prime Number Generation
2. Matrix Multiplication
3. Text Analysis Program
4. Random Number Generation
5. String Manipulation Using Character Arrays
6. String Operations Using String Class
7. String Processing Using StringBuffer
8. Multithreading for Even and Odd Operations
9. Asynchronous Thread Execution
10. Exception Handling Demonstration
11. File Handling and File Properties
12. Text Formatting Using GUI Controls
13. Mouse Event Handling
14. Calculator Using GridLayout
15. Traffic Light Simulation
Page No.
Lab Journal
Date: Title: Prime Number Generation [Link]. 1
Aim:
To develop and implement a Java program that accepts a numerical limit from the user
and identifies all prime numbers up to that limit using conditional and iterative control
statements. This exercise reinforces the use of loops, decision-making constructs, and basic
number logic in Java.
Expected Input:
Expected Output:
Algorithm:
Page No.
Lab Journal
Page No.
Lab Journal
Source Code:
import [Link];
public class PrimeNumbers {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter an integer: ");
int n = [Link]();
[Link]("Prime numbers up to " + n + " are:");
for (int i = 2; i <= n; i++) {
boolean isPrime = true;
// Check if 'i' is prime
for (int j = 2; j <= i / 2; j++) {
if (i % j == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
[Link](i + " ");
}
}
[Link]();
}
}
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Error Reflections:
Errors Observed How Were They Fixed?
Where will you apply this code?
Page No.
Lab Journal
Remarks by the Subject handler:
Result:
Page No.
Lab Journal
Date: Title: Matrix Multiplication [Link]. 2
Aim:
To develop and implement a Java program that multiplies two matrices of compatible
order using multidimensional arrays and nested loops. This exercise helps in understanding
iterative control structures and array manipulation in Java.
Expected Input:
Expected Output:
Algorithm:
Page No.
Lab Journal
Page No.
Lab Journal
Source Code:
import [Link];
public class PrimeNumbers {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter an integer: ");
int n = [Link]();
[Link]("Prime numbers up to " + n + " are:");
for (int i = 2; i <= n; i++) {
boolean isPrime = true;
// Check if 'i' is prime
for (int j = 2; j <= i / 2; j++) {
if (i % j == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
[Link](i + " ");
}
}
[Link]();
}
}
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Error Reflections:
Errors Observed How Were They Fixed?
Where will you apply this code?
Page No.
Lab Journal
Remarks by the Subject handler:
Result:
Page No.
Lab Journal
Date: Title: Text Analysis Program [Link]. 3
Aim:
To develop and implement a Java program that reads text input and counts characters,
words, and lines using string operations and console input handling. This exercise demonstrates
the use of iterative and conditional statements for string processing.
Expected Input:
Expected Output:
Algorithm:
Page No.
Lab Journal
Page No.
Lab Journal
Source Code:
import [Link];
public class PrimeNumbers {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter an integer: ");
int n = [Link]();
[Link]("Prime numbers up to " + n + " are:");
for (int i = 2; i <= n; i++) {
boolean isPrime = true;
// Check if 'i' is prime
for (int j = 2; j <= i / 2; j++) {
if (i % j == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
[Link](i + " ");
}
}
[Link]();
}
}
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Error Reflections:
Errors Observed How Were They Fixed?
Where will you apply this code?
Page No.
Lab Journal
Remarks by the Subject handler:
Result:
Page No.
Lab Journal
Date: Title: Random Number Generation [Link]. 4
Aim:
To develop and implement a Java program that generates random numbers within a
user-specified range using the Random class. The program uses conditional statements to
display messages based on the generated value, demonstrating decision-making and random
number handling.
Expected Input:
Expected Output:
(OR)
(OR)
Algorithm:
Page No.
Lab Journal
Page No.
Lab Journal
Source Code:
import [Link];
public class PrimeNumbers {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter an integer: ");
int n = [Link]();
[Link]("Prime numbers up to " + n + " are:");
for (int i = 2; i <= n; i++) {
boolean isPrime = true;
// Check if 'i' is prime
for (int j = 2; j <= i / 2; j++) {
if (i % j == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
[Link](i + " ");
}
}
[Link]();
}
}
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Error Reflections:
Errors Observed How Were They Fixed?
Where will you apply this code?
Page No.
Lab Journal
Remarks by the Subject handler:
Result:
Page No.
Lab Journal
Date: Title: String Manipulation Using Character [Link]. 5
Arrays
Aim:
To develop and implement a Java program that performs basic string operations such
as finding length, searching for characters, and concatenating two strings using character
arrays. This exercise introduces low-level string manipulation and iterative processing in Java.
Expected Input:
Expected Output:
Algorithm:
Page No.
Lab Journal
Page No.
Lab Journal
Source Code:
import [Link];
public class PrimeNumbers {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter an integer: ");
int n = [Link]();
[Link]("Prime numbers up to " + n + " are:");
for (int i = 2; i <= n; i++) {
boolean isPrime = true;
// Check if 'i' is prime
for (int j = 2; j <= i / 2; j++) {
if (i % j == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
[Link](i + " ");
}
}
[Link]();
}
}
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Error Reflections:
Errors Observed How Were They Fixed?
Where will you apply this code?
Page No.
Lab Journal
Remarks by the Subject handler:
Result:
Page No.
Lab Journal
Date: Title: String Operations Using String Class [Link]. 6
Aim:
To develop and implement a Java program to perform common String class operations
including concatenation, substring searching, and extraction. This exercise highlights
immutable string behavior and built-in string methods.
Expected Input:
Expected Output:
Algorithm:
Page No.
Lab Journal
Page No.
Lab Journal
Source Code:
import [Link];
public class PrimeNumbers {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter an integer: ");
int n = [Link]();
[Link]("Prime numbers up to " + n + " are:");
for (int i = 2; i <= n; i++) {
boolean isPrime = true;
// Check if 'i' is prime
for (int j = 2; j <= i / 2; j++) {
if (i % j == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
[Link](i + " ");
}
}
[Link]();
}
}
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Error Reflections:
Errors Observed How Were They Fixed?
Where will you apply this code?
Page No.
Lab Journal
Remarks by the Subject handler:
Result:
Page No.
Lab Journal
Date: Title: String Processing Using StringBuffer [Link]. 7
Aim:
To develop and implement a Java program that demonstrates mutable string operations
such as reversing a string and deleting a substring using the StringBuffer class. This exercise
emphasizes dynamic string manipulation and performance benefits of mutable strings.
Expected Input:
Expected Output:
Algorithm:
Page No.
Lab Journal
Page No.
Lab Journal
Source Code:
import [Link];
public class PrimeNumbers {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter an integer: ");
int n = [Link]();
[Link]("Prime numbers up to " + n + " are:");
for (int i = 2; i <= n; i++) {
boolean isPrime = true;
// Check if 'i' is prime
for (int j = 2; j <= i / 2; j++) {
if (i % j == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
[Link](i + " ");
}
}
[Link]();
}
}
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Error Reflections:
Errors Observed How Were They Fixed?
Where will you apply this code?
Page No.
Lab Journal
Remarks by the Subject handler:
Result:
Page No.
Lab Journal
Date: Title: Multithreading for Even and Odd [Link]. 8
Operations
Aim:
To develop and implement a Java program using multithreading, where one thread
generates random numbers while other threads concurrently process them. This exercise
reinforces thread creation, synchronization, and concurrent execution in Java.
Expected Input:
Expected Output:
Algorithm:
Page No.
Lab Journal
Page No.
Lab Journal
Source Code:
import [Link];
public class PrimeNumbers {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter an integer: ");
int n = [Link]();
[Link]("Prime numbers up to " + n + " are:");
for (int i = 2; i <= n; i++) {
boolean isPrime = true;
// Check if 'i' is prime
for (int j = 2; j <= i / 2; j++) {
if (i % j == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
[Link](i + " ");
}
}
[Link]();
}
}
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Error Reflections:
Errors Observed How Were They Fixed?
Where will you apply this code?
Page No.
Lab Journal
Remarks by the Subject handler:
Result:
Page No.
Lab Journal
Date: Title: Asynchronous Thread Execution [Link]. 9
Aim:
To develop and implement a Java program that executes multiple tasks asynchronously
using threads. This program helps in understanding concurrent execution, thread scheduling,
and the Thread class or Runnable interface.
Expected Input:
Expected Output:
Algorithm:
Page No.
Lab Journal
Page No.
Lab Journal
Source Code:
import [Link];
public class PrimeNumbers {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter an integer: ");
int n = [Link]();
[Link]("Prime numbers up to " + n + " are:");
for (int i = 2; i <= n; i++) {
boolean isPrime = true;
// Check if 'i' is prime
for (int j = 2; j <= i / 2; j++) {
if (i % j == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
[Link](i + " ");
}
}
[Link]();
}
}
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Error Reflections:
Errors Observed How Were They Fixed?
Where will you apply this code?
Page No.
Lab Journal
Remarks by the Subject handler:
Result:
Page No.
Lab Journal
Date: Title: Exception Handling Demonstration [Link]. 10
Aim:
To develop and implement a Java program that demonstrates handling
runtime exceptions such as ArithmeticException, NumberFormatException,
ArrayIndexOutOfBoundsException, and NegativeArraySizeException. This exercise
emphasizes robust error handling using try-catch-finally blocks.
Expected Input:
Expected Output:
Algorithm:
Page No.
Lab Journal
Page No.
Lab Journal
Source Code:
import [Link];
public class PrimeNumbers {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter an integer: ");
int n = [Link]();
[Link]("Prime numbers up to " + n + " are:");
for (int i = 2; i <= n; i++) {
boolean isPrime = true;
// Check if 'i' is prime
for (int j = 2; j <= i / 2; j++) {
if (i % j == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
[Link](i + " ");
}
}
[Link]();
}
}
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Error Reflections:
Errors Observed How Were They Fixed?
Where will you apply this code?
Page No.
Lab Journal
Remarks by the Subject handler:
Result:
Page No.
Lab Journal
Date: Title: File Handling and File Properties [Link]. 11
Aim:
To develop and implement a Java program that reads a file name from the user and
displays information such as existence, access permissions, type, and size using the File class.
This exercise demonstrates file handling, I/O operations, and file property retrieval.
Expected Input-1:
Expected Input-2:
Expected Output-1:
Expected Output-2:
Algorithm:
Page No.
Lab Journal
Page No.
Lab Journal
Source Code:
import [Link];
public class PrimeNumbers {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter an integer: ");
int n = [Link]();
[Link]("Prime numbers up to " + n + " are:");
for (int i = 2; i <= n; i++) {
boolean isPrime = true;
// Check if 'i' is prime
for (int j = 2; j <= i / 2; j++) {
if (i % j == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
[Link](i + " ");
}
}
[Link]();
}
}
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Error Reflections:
Errors Observed How Were They Fixed?
Where will you apply this code?
Page No.
Lab Journal
Remarks by the Subject handler:
Result:
Page No.
Lab Journal
Date: Title: Text Formatting Using GUI Controls [Link]. 12
Aim:
To develop and implement a Java program that creates a graphical user interface (GUI)
allowing the user to enter text and modify its font size and style. This exercise demonstrates
AWT/Swing components, event handling, and GUI interaction.
Expected Input:
Expected Output:
Page No.
Lab Journal
Algorithm:
Page No.
Lab Journal
Source Code:
import [Link];
public class PrimeNumbers {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter an integer: ");
int n = [Link]();
[Link]("Prime numbers up to " + n + " are:");
for (int i = 2; i <= n; i++) {
boolean isPrime = true;
// Check if 'i' is prime
for (int j = 2; j <= i / 2; j++) {
if (i % j == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
[Link](i + " ");
}
}
[Link]();
}
}
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Error Reflections:
Errors Observed How Were They Fixed?
Where will you apply this code?
Page No.
Lab Journal
Remarks by the Subject handler:
Result:
Page No.
Lab Journal
Date: Title: Mouse Event Handling [Link]. 13
Aim:
To develop and implement a Java program that handles mouse events such as click,
press, release, and movement using adapter classes. This exercise helps in understanding event-
driven programming and graphical user interaction in Java.
Expected Input:
❖ When you run the program:
"Mouse Entered" should be displayed at the center.
❖ When you move the mouse inside the Frame:
"Mouse Moved" should appear.
❖ When you press the mouse button:
"Mouse Pressed" should appear.
❖ When you drag the mouse while pressing a button:
"Mouse Dragged" should appear.
❖ When you release the mouse button:
"Mouse Released" should appear.
❖ When you click the mouse:
"Mouse Clicked" should appear.
❖ When you move the mouse out of the Frame:
"Mouse Exited" should appear.
Expected Output:
Page No.
Lab Journal
Page No.
Lab Journal
Algorithm:
Page No.
Lab Journal
Source Code:
Page No.
Lab Journal
Page No.
Lab Journal
import [Link];
public class PrimeNumbers {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter an integer: ");
int n = [Link]();
[Link]("Prime numbers up to " + n + " are:");
for (int i = 2; i <= n; i++) {
boolean isPrime = true;
// Check if 'i' is prime
for (int j = 2; j <= i / 2; j++) {
if (i % j == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
[Link](i + " ");
}
}
[Link]();
}
}
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Error Reflections:
Errors Observed How Were They Fixed?
Where will you apply this code?
Page No.
Lab Journal
Remarks by the Subject handler:
Result:
Page No.
Lab Journal
Date: Title: Calculator Using GridLayout [Link]. 14
Aim:
To develop and implement a Java program that designs a simple calculator using
GridLayout to perform basic arithmetic operations. The program also demonstrates exception
handling for invalid operations and the use of AWT/Swing GUI components.
Expected Input:
Expected Output:
Page No.
Lab Journal
Algorithm:
Page No.
Lab Journal
Source Code:
Page No.
Lab Journal
Page No.
Lab Journal
import [Link];
public class PrimeNumbers {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter an integer: ");
int n = [Link]();
[Link]("Prime numbers up to " + n + " are:");
for (int i = 2; i <= n; i++) {
boolean isPrime = true;
// Check if 'i' is prime
for (int j = 2; j <= i / 2; j++) {
if (i % j == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
[Link](i + " ");
}
}
[Link]();
}
}
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Error Reflections:
Errors Observed How Were They Fixed?
Where will you apply this code?
Page No.
Lab Journal
Remarks by the Subject handler:
Result:
Page No.
Lab Journal
Date: Title: Traffic Light Simulation [Link]. 15
Aim:
To develop and implement a Java program that simulates a traffic light system using
radio buttons and GUI components. This exercise demonstrates event handling, control
structures, and graphical representation of control systems in Java.
Expected Input:
Expected Output:
Page No.
Lab Journal
Algorithm:
Page No.
Lab Journal
Source Code:
Page No.
Lab Journal
Page No.
Lab Journal
import [Link];
public class PrimeNumbers {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter an integer: ");
int n = [Link]();
[Link]("Prime numbers up to " + n + " are:");
for (int i = 2; i <= n; i++) {
boolean isPrime = true;
// Check if 'i' is prime
for (int j = 2; j <= i / 2; j++) {
if (i % j == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
[Link](i + " ");
}
}
[Link]();
}
}
Page No.
Lab Journal
Page No.
Lab Journal
Page No.
Lab Journal
Error Reflections:
Errors Observed How Were They Fixed?
Where will you apply this code?
Page No.
Lab Journal
Remarks by the Subject handler:
Result:
Page No.
Lab Journal
Page No.