New Lab Manual in Java[1]
New Lab Manual in Java[1]
(LAB MANUAL)
LAB #
REGNO
NAME
DATE
STUDENT
SIGNATURE
Teacher’s Signature
CONTENT
Remarks /
Lab no Objective Signature
3 Arrays
8 Introduction to Inheritance
12 Exception Handling
14 Project Submission
Arrays Lab 3
Array
An array is a group of variables (called elements or components) containing values that all have the same
type. Arrays are objects, so they’re considered reference types. As you’ll soon see, what we typically think of
as an array is actually a reference to an array object in memory. The elements of an array can be either
primitive types or reference types (including arrays, as we’ll see in Section 7.9). To refer to a particular
element in an array, we specify the name of the reference to the array and the position number of the
element in the array.
Syntax:
1. class ArrayDemo{
2. public static void main(String args[]){
3. int array[] = new int[7];
4. for (int count=0;count<7;count++){
5. array[count]=count+1;
6. }
7. for (int count=0;count<7;count++){
8. System.out.println("array["+count+"] = "+array[count]);
9. }
10. //System.out.println("Length of Array = "+array.length);
11. // array[8] =10;
12. }
13. }
1-Write a program using one-dimensional array of numbers and finds the average of a set of numbers.
1. class Average {
2. public static void main(String args[]) {
3. double nums[] = {10.1, 11.2, 12.3, 13.4, 14.5};
4. double result = 0;
5. int i;
6. for(i=0; i<5; i++)
7. result = result + nums[i];
8. System.out.println("Average is " + result / nums.length);
9. }
10. }
11.
Foreach Loops
In Java, the enhanced for loop, also known as the foreach loop, provides a concise way to iterate over arrays
and collections. Here's the basic syntax for a foreach loop in Java
4- Write a Java program that calculates the sum of all elements in an integer array using a foreach loop.
1. Write a Java program that checks whether a given string is a palindrome or not. Ex: CIVIC is palindrome?
2. Write a Java program for sorting a given array of numbers in ascending order?
3. Write a program to sort an array of strings.
4. Write a Java program to multiply two given matrices using 2D array.
Introducing Classes and Objects Lab 4
Objective: Understanding concepts of class and object in java. Implementing a class with members including
data, methods and constructors.
Classes
A class consists of
• Data(variables)
• Methods
• Constructors
Classes are constructs that define objects of the same type. A Java class uses variables to define data fields
and methods to define behaviors. Additionally, a class provides a special type of methods, known as
constructors, which are invoked to construct objects from the class.
class Circle {
/** The radius of this circle */
double radius = 1.0; Data field
Constructors in Java
In Java, a constructor is a block of codes similar to the method. It is called when an instance of the class is
created. At the time of calling constructor, memory for the object is allocated in the memory.
class Box {
double width;
double height;
double depth;
// This is the constructor for Box.
Box() {
System.out.println("Constructing Box");
width = 10;
height = 10;
depth = 10;
}
// compute and return volume
double volume() {
return width * height * depth;
}
}
Lab # 4 Assignment:
• The class should contain default and parameterized constructor. The constructors should just print the
statement as follows.
▪ “Inside Default Constructor”
▪ “Inside Parameterized Constructor”.
Objective:
The goal of this lab is to understand and implement the concept of methods in Java. You will learn how to
define, call, and utilize methods to perform specific tasks, promote code reusability, and improve program
structure and readability.
Methods
Methods are functions that are associated with classes and objects. They define the behavior of objects and
allow them to perform specific actions or operations. Methods in Java shows/perform the behavior of
objects by bundling related functionality together.
Syntax :
In Java, methods are defined using a syntax that specifies the method's name, return type, parameters (if
any), and the code block that contains the method's implementation.
1. // Method declaration
2. returnType methodName(parameterType1 parameter1, parameterType2 parameter2, ...) {
3. // Method body (code block)
4. // Perform task using parameters
5. // Optionally, return a value using the return statement
6. }
Access Modifiers: Methods in Java can have access modifiers like public, private, protected, or default (no
modifier). These modifiers control the visibility and accessibility of methods from other parts of the program.
Return Type: Methods in Java can optionally specify a return type, which indicates the type of value that the
method returns after execution. If a method does not return any value, its return type is specified as void.
Parameters: Methods in Java can accept zero or more input parameters (arguments), which are specified
within parentheses after the method name. Parameters allow you to pass data to a method for processing.
Method Overloading: Java supports method overloading, which allows multiple methods with the same
name but different parameter lists to coexist within the same class. This provides flexibility and allows for
methods with similar functionality to be grouped together.
Method Invocation/Calling: Methods in Java are invoked using dot notation (object.method() or
class.method()), where the method is called on an object or class instance. The method's code is executed
when it is invoked.
Static Methods: Java allows the declaration of static methods, which are associated with the class itself
rather than individual objects. Static methods can be called directly on the class without needing to create an
instance of the class.
Instance Methods: Instance methods in Java are associated with individual objects created from a class.
They operate on the state of the object and can access instance variables and other instance methods.
1- Create a program in which create a method void type without any parameters and print any statement
in a body.
12. class Activity {
13. // method without return type
14. public void method() {
15. System.out.println("hello");
16. }
2-Create a program to get sum of two values by a method which take two parameters and don’t return
anything.
1. class Activity2 {
2. // method with parameters:
3. public void sum(int a, int b) {
4. result = a + b;
5. System.out.println("Sum : " + a + " + " + b + " = " + result);
6. }
7.}
3- Create a program to get power of a number by a method which take two parameters and return the
power without using Math.pow() function.
Lab Objective:
The objective of this lab is to understand the concept of encapsulation in Java and practice implementing encapsulation
in classes.
Encapsulation:
Encapsulation is one of the fundamental principles of object-oriented programming (OOP) that refers to the bundling of
data (variables) and methods (functions) that operate on the data into a single unit, called a class. It allows the internal
state of an object to be hidden from the outside world, and only allows access to it through well-defined interfaces. In
simpler terms, encapsulation helps in hiding the implementation details of a class from its users and provides a
controlled way to access and modify data.
• Declare Data Members as Private: Make instance variables private to prevent direct access from outside the class.
• Provide Getter and Setter Methods: Create public getter methods to retrieve the values of private variables, and
public setter methods to modify the values of private variables. These methods should act as controlled interfaces
for accessing and modifying data.
• Encapsulate Complex Data Types: If your class contains complex data types (e.g., arrays, collections), ensure that
they are also encapsulated properly. Provide methods to interact with these data types, rather than exposing them
directly.
• Ensure Data Validation: Implement data validation checks within setter methods to ensure that the data remains
consistent and valid. For example, you can check if a value being set violates any constraints or business rules.
Public (public):
● Public members are accessible from any other class.
There is no restriction on accessing public members.
// code here
Private (private):
// code here
Protected (protected):
● Protected members are accessible within the same class, same package, and subclasses in other
packages.
● They are not accessible to unrelated classes in different packages.
// code here
}
}
Default (Package-Private):
● If no access modifier is specified (also known as package-private or default access), it is visible only
within the same package.
● It is not visible to classes outside the package.
class MyClass {
int myPackagePrivateVariable;
void myPackagePrivateMethod() {
// code here
Exercise 1:
Exercise 2:
Exercise 3:
The objective of this lab is to understand and practice the concepts of arrays of objects and method
overloading in Java programming. By the end of this lab, participants should be able to:
Method Overloading:
Method overloading refers to the capability of defining multiple methods with the same name but with
different parameter lists within the same class. The Java compiler uses the number and types of arguments
provided to determine which method to execute. Here's a simple example to illustrate method overloading.
Task 1
To practice method overloading by creating multiple add() methods to perform different tasks.
Instructions:
Create a Java class named Calculator.Define multiple overloaded add() methods within the Calculator class as
described below.Test each add() method by invoking them with different arguments from the main() method.
Requirements:
• add(): This method should take two integer inputs from user and display their sum.
• add(int a): This method should take one integer input and display the result of adding it to itself.
• add(int a, int b): This method should take two integer inputs and display their sum.
• add(double a): This method should take one double input and display the result of adding it to itself.
• add(int[] arr): This method should take an integer array as input and display the sum of all elements in the
Array.
Task 2
To practice method overloading in Java by creating a class named AreaCalculator with overloaded methods
to calculate the area of different shapes such as rectangle, circle, and triangle.
Array of Object:
an array of objects can be created to store multiple instances of a particular class. Here's a simple example
demonstrating how to create an array of objects in Java
class Book { class Library {
private String title; private Book[] books;
private String author; private int capacity;
private int numberOfBooks;
// Constructor
public Book(String title, String author) { // Constructor
this.title = title; public Library(int capacity) {
this.author = author; this.capacity = capacity;
} books = new Book[capacity];
numberOfBooks = 0;
// Getter methods }
public String getTitle() {
return title; // Add a book to the library
} public void addBook(Book book) {
if (numberOfBooks < capacity) {
public String getAuthor() { books[numberOfBooks] = book;
return author; numberOfBooks++;
} System.out.println("Book added to the
library.");
} else {
System.out.println("Library is full. Cannot add
more books.");
}
}
• id (int)
• name (String)
• gender (char)
• contactData (String)
Assignment:
Write a Java program to create a class named Student with the following data fields: id, name, lastName,
and fatherName. Include appropriate constructors and getter methods.
• Implement a class named School that contains an array of Student objects. The School class should have
overloaded methods for searching students based on different criteria.
• Implement an overloaded method in the School class named searchStudent that takes an integer id as
input and print the student's details if match found. If no student is found with the given ID, return null.
• Implement another overloaded method in the School class named searchStudent that takes a String
lastName as input and print the students detail if match found. If no student is found with the given last
name, return an empty array.
• Write a method which display total number or male and female in the class.
• Implement a method for adding the students in array.
Inheritance Lab 8
Inheritance
In programming, inheritance is like building blocks where you create a main block with some common
features. This main block is called a superclass. Then, you can make smaller blocks, called subclasses, that
inherit from the main one. These subclasses add their own special features to the common ones. So,
inheritance helps in organizing and reusing code efficiently. In Java, the main block is the superclass, and the
smaller blocks inheriting from it are subclasses. It's a way to make code more structured and easier to
manage.
Syntax :
In Java, inheritance is implemented using the “extends” keyword. Here's the basic syntax:
// inheritance syntax
1. // parent class
2. class Superclass {
3. // Superclass members and methods
4. }
5. // child class / sub class
6. class Subclass extends Superclass {
7. // Subclass members and methods
8. }
// Syntax -2
1. // parent class
2.
3. class Animal {
4. void eat() {
5. System.out.println("Animal is eating...");
6. }
7. }
8. // child/sub class
9.
10. class Dog extends Animal {
11. void bark() {
12. System.out.println("Dog is barking...");
13. }
14. }
Types Of Inheritance
1.Single Inheritance: This is the simplest form, where a subclass inherits from only one
superclass. It's like passing down traits from one parent to one child. For example, a Car class
may inherit from a Vehicle class.
2.Multilevel Inheritance: In this type, a subclass can inherit from another subclass, creating a
chain of inheritance. It's like generations in a family tree, where traits pass from grandparents
to parents and then to children. For instance, a SUV class may inherit from a Car class, which in
turn inherits from a Vehicle class.
3.Hierarchical Inheritance: Here, multiple subclasses inherit from a single superclass. It's like
siblings sharing traits from the same parent. For example, both Car and Motorcycle classes may
inherit from a common Vehicle class.
Task 1
create a class called `Person` with attributes `id` and `name`. Use a constructor to get user input
for these attributes. Implement a method `display()` to show the person's details.
Then, create a class `Student` that extends `Person`. Add attributes `regNo` and `program`. In its
constructor, get user input for these attributes and call the superclass constructor to set `id` and
`name`. Include a method `viewDetails()` to display the student's information.
Task 2
Create a Java class named Person with attributes id and name. Develop a constructor method
within this class and pass parameters id and name, initializing the attributes accordingly.
Additionally, include a method named display() to display the details of the person. Now, create
a subclass named Employee, extending the Person class. Introduce specific attributes for
employees, such as employeeNo, deptNo, and des (designation). Within the constructor
method of the Employee class, prompt the user to input values for employeeNo and deptNo,
while simultaneously calling the superclass constructor to set id and name. Implement a
method named view() to present information about an employee, including both personal and
employment details
}
class Circle extends Shape{
double radius;
JavaFX LAB 9
Objectives:
To familiarize students with JavaFX, its components, and event handling mechanisms through hands-on
exercises. By the end of the lab, students should be able to create interactive user interfaces using JavaFX,
understand the lifecycle of JavaFX applications, and handle user input effectively.".
javaFX:
JavaFX is a set of Java libraries for building desktop and rich internet applications (RIAs) that can run across
multiple platforms. It provides a comprehensive toolkit for creating modern graphical user interfaces (GUIs),
animations, multimedia, and interactive content in Java. JavaFX supports a wide range of features including
2D and 3D graphics, audio and video playback, and integration with web technologies
Stage
Scene
● A scene represents the physical contents of a JavaFX application. It contains all the contents of a
scene graph.
Scene Graph
● A scene graph is a tree-like data structure (hierarchical) representing the contents of a scene.
● Geometrical (Graphical) objects (2D and 3D) such as − Circle, Rectangle, Polygon, etc.
● UI Controls such as − Button, Checkbox, Choice Box, Text Area, etc.
● Containers (Layout Panes) such as Border Pane, Grid Pane, Flow Pane, etc.
● Media elements such as Audio, Video and Image Objects.
Layouts
● VBox (Vertical Box): Arranges its children nodes in a single vertical column.
VBox vbox = new VBox();
vbox.getChildren().addAll(node1, node2, node3);
● HBox (Horizontal Box): Arranges its children nodes in a single horizontal row.
HBox hbox = new HBox();
hbox.getChildren().addAll(node1, node2, node3);
● BorderPane: Divides the space into five regions: top, bottom, left, right, and center.
BorderPane borderPane = new BorderPane();
borderPane.setTop(topNode);
borderPane.setLeft(leftNode);
borderPane.setCenter(centerNode);
borderPane.setRight(rightNode);
borderPane.setBottom(bottomNode);
● StackPane: Stacks its children nodes on top of each other. Useful for layering nodes.
StackPane stackPane = new StackPane();
stackPane.getChildren().addAll(node1, node2, node3);
Task 1:
Task 2:
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
signin.setOnAction(e -> {
String username = usernameInput.getText();
String password = passwordInput.getText();
Lab Assignment:
Design a Simple calculation with basic operation such as addition, multiplication, subtraction & Division.
Abstract Class & Interfaces Lab 10
Objective
The objective of this lab is to understand the concepts of abstract classes and interfaces in Java and their
respective use cases. By the end of this lab, students should be able to differentiate between abstract classes
and interfaces and implement them in practical scenarios.
Abstract Class:
• An abstract class is a class that cannot be instantiated on its own; it must be subclassed.
• It can contain both abstract (methods without a body) and concrete methods (methods with
implementation).
• Abstract methods in an abstract class must be implemented by subclasses, providing a way to
enforce certain behaviors across subclasses.
• Abstract classes can also have fields and constructors.
• Abstract classes are used when you have a common base implementation to share among several
related classes.
Syntax :
1. abstract class Animal {
2. String name;
3.
4. Animal(String name) {
5. this.name = name;
6. }
7.
8. abstract void sound();
9. }
10.
11. class Dog extends Animal {
12. Dog(String name) {
13. super(name);
14. }
15.
16. void sound() {
17. System.out.println(name + " says Woof");
18. }
19. }
Activity 1:
•
Create an abstract class named BankAccount.
•
Include data fields for account number (accountNumber), account holder's name
(accountHolderName), and account balance (balance).
• Include abstract methods deposit, withdraw, and checkBalance.
Implement Deposit Method:
• Implement the deposit method which takes a parameter for the deposit amount and adds it to
the account balance.
Implement Withdraw Method with Validation:
• Implement the withdraw method with validation criteria:
• Ensure that the withdrawal amount is greater than 499.
• Ensure that the withdrawal amount is divisible by 500.
• Deduct the withdrawal amount from the account balance if the validation passes.
• If the validation fails, print an appropriate error message.
Implement Check Balance Method:
• Implement the checkBalance method to return the current account balance.
Create Subclasses:
Create concrete subclasses such as HBL and JS that extend the BankAccount class.
Provide implementations for the abstract methods in each subclass.
Interface:
• An interface is a reference type in Java that is similar to a class but contains only constants, method
signatures, default methods, static methods, and nested types.
• All methods in an interface are implicitly abstract and public (before Java 8), or they can be declared
as default or static (Java 8 and later).
• A class implements an interface, thereby inheriting the abstract methods of the interface.
• Interfaces provide a way to achieve multiple inheritance in Java, as a class can implement multiple
interfaces.
• Interfaces are used when you want to specify a set of methods that a class must implement,
irrespective of the actual implementation.
Syntax :
1. interface Animal {
2. void sound();
3. }
4.
5. class Dog implements Animal {
6. public void sound() {
7. System.out.println("Woof");
8. }
9. }
Acitvity 2:
Define Interface:
Implement Interface:
Objectives:
Generic Class:
A generic class allows you to create classes that can work with any data type. Here's a simple example of a
generic class .
Object Class.
Object class is present in java.lang package. Every class in Java is directly or indirectly derived from
the Object class. If a class does not extend any other class then it is a direct child class of Object and if
extends another class then it is indirectly derived. Therefore the Object class methods are available to all Java
classes. Hence object class acts as a root of the inheritance hierarchy in any Java Program.
Task 1:
Write a Java program where an Array can contain multiple values of different types.
package lab13;
package lab13;
}
}
Task 2
Create a generic class in Java where the type of array or list is specified by an object. The class should have
methods for adding elements by index to the array or list and searching for elements within it. Use required
arguments in methods
package lab13;
}
void search(E val) {
Boolean check=false;
for(int i=0;i<list.length;i++) {
if(list[i]==val) {
System.out.println("Record found at index :"+i);
check=true;
break;
}
}
if(!check) {
System.out.println("Record not Found");
}
}
}
Collection:
Collection refers to a framework or set of classes and interfaces in the Java Collections Framework (JCF) that
provides an architecture to store and manipulate groups of objects. Collections provide various data
structures and algorithms to efficiently handle data, offering flexibility, performance, and ease of use.
1. Java Collections Framework (JCF): Introduced in Java 2, the JCF provides a unified architecture for
representing and manipulating collections. It includes interfaces such as List, Set, Map, and classes such
as ArrayList, LinkedList, HashSet, HashMap, etc.
2. Interfaces: Interfaces in the JCF define common behaviors and operations for different types of
collections. For example, the List interface represents an ordered collection of elements, the Set
interface represents a collection that does not allow duplicate elements, and the Map interface
represents a mapping of keys to values.
3. Classes: Classes in the JCF provide implementations of these interfaces. For example, ArrayList and
LinkedList implement the List interface, HashSet and TreeSet implement the Set interface, and HashMap
and TreeMap implement the Map interface.
4. Common Operations: Collections support common operations such as adding and removing elements,
accessing elements by index or key, searching for elements, iterating over elements, and more.
5. Generics: Java collections extensively use generics to provide type safety. Generics allow you to specify
the type of elements that a collection can contain, reducing the need for explicit type casting and
improving compile-time type checking.
ArrayList:
An ArrayList in Java is a resizable array implementation of the List interface provided by the Java Collections
Framework. It's a dynamic data structure that can grow or shrink in size as needed.
import java.util.ArrayList;
// Removing an element
arrayList.remove("Banana");
System.out.println("After removing Banana:");
for (String element : arrayList) {
System.out.println(element);
}
}
}
Lab Assignment:
You are tasked with implementing a generic class called ShoppingCart to simulate a shopping cart
functionality. This class should be able to store items of any data type. You will utilize an user defined
ArrayList to manage the items internally.
Requirements:
● Create an instance of ShoppingCart to store items of different types (e.g., Electronics, Groceries,
Clothing).
● Add items to the cart and display the cart contents.
● Remove items from the cart and display the updated cart contents.
● Calculate and display the total number of items and the total cost of the items in the cart.
Exception Handling Lab 12
Objective:
The objective of this lab session is to introduce students to the concept of exception handling in Java
Exception in OOP:
Exception handling allows you to deal with unexpected or erroneous situations that may occur during
program execution. Here's a basic overview of how it works:
• Try Block: The code that may throw an exception is enclosed within a try block.
• Catch Block(s): If an exception occurs within the try block, it's caught by a corresponding catch block.
Each catch block handles a specific type of exception.
• Finally Block: This block, if included, is executed whether an exception occurs or not. It's typically
used for cleanup tasks like closing files or releasing resources.
• Throw Keyword: You can use the throw keyword to manually throw an exception. This is useful when
you want to handle exceptional situations explicitly.
package demo;
import java.util.*;
public class Driver {
try {
index=in.nextInt();
if(arr[index]%2==0) {
System.out.println("Even number :"+arr[index]);
}
else {
System.out.println("Odd number :"+arr[index]);
}
}
catch(ArrayIndexOutOfBoundsException e) {
System.out.println("Wrong Index");
}
catch(InputMismatchException e) {
System.out.println("Wrong input type"+e.getMessage());
}
System.out.println("After Exception");
}
Task 3:
package demo;
import java.util.*;
public class Driver {
}
for(int i=0;i<arr.length;i++) {
System.out.println(arr[i]);
}
int index;
System.out.println("Enter An index");
try {
index=in.nextInt();
if(arr[index]%2==0) {
System.out.println("Even number :"+arr[index]);
}
else {
System.out.println("Odd number :"+arr[index]);
}
}
catch(ArrayIndexOutOfBoundsException e) {
System.out.println();
}
package demo;
import java.util.*;
public class Driver {
int val=in.nextInt();
if(val>=10) {
System.out.println("Valid input");
}
else {
try {
throw new ArithmeticException("Demo ************");
}
catch(ArithmeticException e) {
System.out.println("Caught by user");
}
}
}
}
Lab Assignment:
Files, Streams and Object Serialization Lab 13
Objective:
The objective of this lab is to provide students with hands-on experience in working with files, streams, and
object serialization in Java
Files
Files can be classified as either text or binary.
Text File
A file that can be processed (read, created, or modified) using a text editor is called a text file.
Binary File
All files other than text files are called binary files.
For example,
Java source programs are stored in text files and can be read by a text editor, but Java class files are stored in
binary files and are read by the JVM.
• File object encapsulates the properties of a file but does not contain the methods for reading/writing
data from/to a file
• In order to perform I/O, objects using appropriate Java I/O classes need to be created.
I/O classes can be classified as input classes and output classes.
• FileWriter, BufferedWriter, PrintWriter are output classes
• FileReader, BufferedFileReader, Scanner are input classes
Task 1: Create a Java program that writes a specified text string to a text file. The program should follow
these steps:
• Initialize a FileWriter object to create or open a file where the text will be written.
• Wrap the FileWriter in a BufferedWriter to enhance writing efficiency by reducing the number of I/O
operations.
• Use the BufferedWriter to write the text string to the file.
• Ensure that the BufferedWriter is properly closed to flush any remaining data from the buffer to the
file and release system resources.
bufWriter.close();
Task 2 Create a Java program that reads the content from a text file and displays it on the console. The
program should follow these steps:
• Initialize a FileReader object to open the file from which the text will be read.
• Wrap the FileReader in a BufferedReader to enhance reading efficiency by allowing buffered reading
of characters, arrays, and lines.
• Use the BufferedReader to read the text from the file line by line.
• Print each line to the console as it is read.
• Ensure that the BufferedReader is properly closed to release system resources associated with the
stream.
Object I/O
Serialization
• Serialization in java is a mechanism of writing the state of an object into a byte stream.
• An object can be represented as a sequence of bytes (that includes the object's data as well as information
about the object's type and the types of data stored in the object) in the file. This mechanism is called Object
Serialization
Deserialization
• An Object can be read from the file, the type information and bytes that represent the object and its data
can be used to recreate the object in memory. This mechanism is called Object Deserialization
Task 3: Create a Java program that saves the state of a Student class instance to a file using serialization.
The program should follow these steps:
Task 4: Create a Java program that reads and restores the state of a student class instance from a file using
deserialization. The program should follow these steps:
Lab Assignment :
• Define a Serializable Book Class: Create a Book class that implements the Serializable interface. This
class represents a book in the library and includes attributes such as title, author, ISBN, genre, and
availability status. Ensure all fields are serializable to facilitate smooth storage and retrieval.
• Generate Book Records: Simulate the library's catalog by generating an array of Book objects.
Populate these objects with relevant data, including titles, authors, ISBNs, genres, and availability
statuses, reflecting the library's collection.
• Serialization: Serialize the array of Book objects to a file. Use ObjectOutputStream to write the array
to a file in a serialized format. This step mimics the system's action of persistently storing book
records for future access and management.
• Deserialization: Implement the deserialization process to restore the array of Book objects from the
file. Utilize ObjectInputStream to read the serialized objects from the file and reconstruct the array.
This mirrors the system's functionality in retrieving book records from storage.
• Verification and Processing: After deserialization, verify that the array of Book objects has been
successfully restored to its original state. Perform operations such as searching for specific books,
updating availability statuses, or calculating statistics on the library's collection to validate data
integrity.