Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
16 views27 pages

Java LAB MANUAL (Students Copy)

Uploaded by

Prakash More
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)
16 views27 pages

Java LAB MANUAL (Students Copy)

Uploaded by

Prakash More
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
You are on page 1/ 27

LABORATORY MANUAL

Full Stack Java Programming (2113611)

SE (SEM-III)
(A.Y. 2025-26)

DEPARTMENT OF COMPUTER ENGINEERING

Xavier Institute of Engineering


(Affiliated to Mumbai University)

(Student)
Institute Vision and Mission

Vision of Institute
To nurture the joy of excellence in a world of high technology.

Mission of Institute
To strive to match Global Standards in Technical Education by Interaction with Industry,
Continuous Staff Training and Development of Quality of Life.

Department Vision and Mission

Vision of Computer Department


To nurture the joy of excellence in the world of Computer Engineering.

Mission of Computer Department


M1: To provide students the knowledge of computer engineering with related technical skills to
solve various computer engineering problems
and to have industry interaction.

M2: To motivate the students to acquire additional soft skills to sharpen their technical and
professional skills that make them employable.

M3: To nurture social and professional ethics in our undergraduates and encourage them to
have lifelong learning.
Program Specific Objectives (PSO)

The ability to understand, analyze and apply knowledge to address computing


PSO1 problems.

The ability to design and implement software solutions to meet the end users
PSO2 requirements.

Program Educational Objectives (PEOs)

Graduates will have the required knowledge of computer engineering, to design


PEO1
and develop systems that can cater to a multi-disciplinary environment.

Graduates will be able to apply the art of self-learning to use the modern tools
PEO2
in solving computer engineering problems.

Graduates will be prepared in the field of computer engineering to have lifelong-


PEO3
learning in the global and ethic context.

Graduates will be able to inculcate professional and ethical attitude with good
PEO4 leadership qualities and have commitment to social responsibilities in their
thought process.
PROGRAM OUTCOMES (POs)

Engineering knowledge: Apply knowledge of mathematics, natural science,


1 computing, engineering fundamentals and an engineering specialization to develop
to the solution of complex engineering problems.
Problem analysis: Identify, formulate, review research literature and analyze complex
2 engineering problems reaching substantiated conclusions with consideration for
sustainable development.
Design/development of solutions: Design creative solutions for complex engineering
problems and design/develop systems/components/processes to meet identified
3
needs with consideration for the public health and safety, whole-life cost, net zero
carbon, culture, society and environment as required.
Conduct investigations of complex problems: Conduct investigations of complex
engineering problems using research-based knowledge including design of
4
experiments, modelling, analysis & interpretation of data to provide valid
conclusions.
Engineering Tool Usage: Create, select and apply appropriate techniques, resources
5 and modern engineering & IT tools, including prediction and modelling recognizing
their limitations to solve complex engineering problems.
The Engineer and The World: Analyze and evaluate societal and environmental
aspects while solving complex engineering problems for its impact on sustainability
6
with reference to economy, health, safety, legal framework, culture and
environment.
Ethics: Apply ethical principles and commit to professional ethics, human values,
7
diversity and inclusion; adhere to national & international laws.
Individual and Collaborative Team work: Function effectively as an individual, and as
8
a member or leader in diverse/multi-disciplinary teams.
Communication: Communicate effectively and inclusively within the engineering
community and society at large, such as being able to comprehend and write
9
effective reports and design documentation, make effective presentations
considering cultural, language, and learning differences.
Project Management and Finance: Apply knowledge and understanding of
engineering management principles and economic decision-making and apply these
10
to one’s own work, as a member and leader in a team, and to manage projects and in
multidisciplinary environments.
Life-Long Learning: Recognize the need for, and have the preparation and ability for i)
11 independent and life-long learning ii) adaptability to new and emerging technologies
and iii) critical thinking in the broadest context of technological change.
Lab Rules
DO’S

● Without prior permission do not enter into the Laboratory.


● While entering into the LAB students should wear their ID cards.
● The students should come with proper uniform.
● Students should come with observation and record note book to the laboratory.
● Students should maintain silence inside the laboratory.
● After completing the laboratory exercise, make sure to shut down the system properly.

DONT’S

● Students bringing the bags inside the laboratory.


● Students using the computers in an improper way.
● Students scribbling on the desk and mishandling the chairs.
● Students using mobile phones inside the laboratory.
● Students making noise inside the laboratory.
COURSE NAME: Full Stack Java Programming

COURSE CODE: 2113611

H/w Requirements: PC i3 processor and above

S/w Requirements: JDK & MySQL

LAB OBJECTIVES:
1. Familiarize with Basic OOP concepts in Java.
2. Understand the concepts of inheritance and exceptions in java.
3. Design and implement programs involving Client and Server Side Programming.
4. Describe and utilize the functioning of DOM and Java script.
5. Study different design patterns in web programming and understand the working of react framework.
6. To describe the Spring Framework and implement the related case studies.

COURSE OUTCOMES:
Course Name Full Stack Java Programming
Course Code 2113611
Faculty Name Ms. Nilambari Narkar & Ms. Kirti Motwani
Year SE SEM III A.Y. 2025-26
CO Number Course Outcome (The student will be able to ) BT Level
Apply the fundamentals of Java Programming and Object-
2113611.1 L3
Oriented Programming.

2113611.2 Illustrate Inheritance and Exception Handling Mechanisms. L3

Develop applications using Client and Server Side


2113611.3 L3
Programming.

Apply the concepts in JavaScript for interactive Web


2113611.4 L3
Development.

Implement the real-world application development in web


2113611.5 L3
programming using React.

Develop Enterprise-Level Applications Using the Spring


2113611.6 L3
Framework.
MAPPING OF LAB OUTCOMES WITH PROGRAM OUTCOMES :

PO PO
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PSO1 PSO2
10 11
LO1
LO2
LO3

LO4

LO5

LO6
Full Stack Java Programming (2113611)
Exp.
Title of the Experiment LO’s BL’s PO’s, PSO’s
No.
Basic programming constructs :
1.1 Implement a program to find a maximum of four
PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9,
1 numbers. BL3 LO1
PO11, PSO1, PSO2
1.2 Implement a function prime to check the number
entered by user is prime or not.
Implement a class to represent a bank account.
Include the following members:
 Name of the depositor
 Account number
 Type of Account
 Balance amount in the account PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9,
2 BL3 LO1
Methods: PO11, PSO1, PSO2
 To assign initial values (Use constructor)
 To deposit an amount
 To withdraw an amount after checking
balance
 To display the name and balance.
Implement a menu driven program to calculate the
PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9,
3 area of triangle, rectangle and circle using method BL3 LO1
PO11, PSO1, PSO2
overloading.
An educational institution wishes to maintain a
database of its employees. The database is divided
into a number of classes whose hierarchical
relationships as shown in the figure below. Specify
all the classes and retrieve individual information as
and when required.

PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9,


4 BL3 LO2
PO11, PSO1, PSO2

Exceptions:
PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9,
5 5.1 Demonstrate try, catch, throw, throws and finally. BL3 LO2
PO11, PSO1, PSO2
5.2 Demonstrate user defined exception.
Implement login webpage in JSP that makes
PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9,
6 validation through Database using JDBC and call the BL2 LO3
PO11, PSO1, PSO2
servlets for various operations.
Implement a website using HTML CSS and PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9,
7 BL3 LO3
JavaScript (create your own profile page) PO11, PSO1, PSO2
Implement a program using Java Script to validate
the email address entered by the user (check the
presence of “@” & “.” character. If this character is PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9,
8 BL3 LO4
missing, the script should display an alert box PO11, PSO1, PSO2
reporting the error and ask the user to re-enter it
again).
Implement a program based on Document Object
PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9,
9 Model to change the background color of the web BL3 LO4
PO11, PSO1, PSO2
page automatically after every 5 seconds.
Implement a program for making use of React Hooks
that displays four buttons namely, “Red”, “Blue”,
PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9,
10 “Green”, “Yellow”. On clicking any of these buttons, BL3 LO5
PO11, PSO1, PSO2
the code displays the message that you have selected
that particular color.
Implement a program to create a Monolithic PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9,
11 BL3 LO6
Application using SpringBoot PO11, PSO1, PSO2
LO1- PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9,
12 Mini Project BL3
LO6 PO11, PSO1, PSO2

Implement a program on collections. (Beyond LO1- PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9,
13 BL3
Syllabus) LO6 PO11, PSO1, PSO2
Experiment No. 1

Aim: Basic programming constructs:


1.1 Implement a program to find a maximum of four numbers.
1.2 Implement a function prime to check the number entered by user is prime or not.

Theory:
Java provides basic programming constructs like variables, data types, conditional statements, loops, and functions
that form the foundation of any program.

1.1 Implement a Program to Find Maximum of Four Numbers

 To find the maximum of four numbers, we use conditional statements (if-else).

 Steps in Java:

1. Accept four numbers from the user using Scanner.

2. Initialize a variable max with the first number.

3. Compare max with other numbers using if conditions.

4. Update max whenever a bigger number is found.

5. Finally, display max as the result.

1.2 Implement a Function prime to Check if a Number is Prime

 A prime number is a number greater than 1 that has no divisors other than 1 and itself.

 In Java, we can create a method to check if a number is prime.

 Steps:

1. If number ≤ 1, it is not prime.

2. Check divisibility of the number from 2 to √n (square root of n).

3. If divisible by any number, it is not prime; otherwise, it is prime.


Conclusion: Thus we have successfully studied & implemented Basic programming constructs.

LOs Achieved: LO1

POs Achieved: PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9, PO11

PSOs Achieved: PSO1, PSO2


Experiment No. 2

Aim: Implement a class to represent a bank account. Include the following members:
 Name of the depositor
 Account number
 Type of Account
 Balance amount in the account
Methods:
 To assign initial values (Use constructor)
 To deposit an amount
 To withdraw an amount after checking balance
To display the name and balance.

Theory:
Class:
A class in Java is a blueprint or template from which objects are created.
It defines data members (variables) and methods (functions) that represent the behavior of the object.
Object:
An object is an instance of a class.
It occupies memory and has its own identity, state, and behavior.
Constructor:
A constructor is a special method in Java that is used to initialize objects of a class.
It is automatically called when an object is created using the new keyword.
A constructor has the same name as the class and does not have a return type, not even void.
new keyword:
The new keyword in Java is used to create objects dynamically during runtime.
When you use new, it Allocates memory in the heap for the object.
Calls the constructor to initialize the object.
Steps in Object-Oriented Programming:-
1. Define the class with variables and methods.
2. Create objects using the new keyword.
3. Access members using the object (objectName.variable or objectName.method()).
4. Initialize data using constructors or setter methods.
5. Retrieve or display data using getter methods or print statements.

Conclusion: Thus we have successfully studied & implemented a class & object using constructor.

LOs Achieved: LO1

POs Achieved: PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9, PO11

PSOs Achieved: PSO1, PSO2


Experiment No. 3

Aim: Implement a menu driven program to calculate the area of triangle, rectangle and circle using method
overloading.

Theory:
Method overloading means defining multiple methods with the same name in a class, but with different parameter
lists.
Rules:
 All overloaded methods must have the same name.
 Method overloading is based on parameter count, type, or order — at least one of these must differ.
 All overloaded methods must be defined in the same class or inherited from a superclass.
 Overloaded methods can have different access modifiers (public, private, etc.), but it’s not a rule — only allowed.

Conclusion: Thus we have successfully studied & implemented method overloading.

LOs Achieved: LO1

POs Achieved: PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9, PO11

PSOs Achieved: PSO1, PSO2


Experiment No. 4

Aim: An educational institution wishes to maintain a database of its employees. The database is divided into a
number of classes whose hierarchical relationships as shown in the figure below. Specify all the classes and retrieve
individual information as and when required.

Theory:
Inheritance:-
Inheritance is a fundamental concept in OOP(Object-Oriented Programming). It is the mechanism in Java by which one
class is allowed to inherit the features (fields and methods) of another class
Hierarchical Inheritance
In Hierarchical Inheritance, one class serves as a superclass (base class) for more than one subclass. In the below
image, class A serves as a base class for the derived classes B, C, and D.

Conclusion: Thus we have successfully studied & implemented a Hierarchical Inheritance.

LOs Achieved: LO2

POs Achieved: PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9, PO11

PSOs Achieved: PSO1, PSO2


Experiment No. 5

Aim: Exceptions:
5.1 Demonstrate try, catch, throw, throws and finally.
5.2 Demonstrate user defined exception.

Theory: Exception Handling


try and catch:
It uses different keywords:
The try statement allows you to define a block of code to be tested for errors while it is being executed.
The catch statement allows you to define a block of code to be executed, if an error occurs in the try block.
The try and catch keywords come in pairs:
Syntax
try {
// Block of code to try
}
catch(Exception e) {
// Block of code to handle errors
}
Finally:
The finally statement lets you execute code, after try...catch, regardless of the result.
The throw keyword:
The throw statement allows you to create a custom error.
The throw statement is used together with an exception type. There are many exception types available in
Java: ArithmeticException, FileNotFoundException, ArrayIndexOutOfBoundsException, SecurityException,
etc
The throws keyword:
throws is a keyword in Java that is used in the signature of a method to indicate that this method might
throw one of the listed type exceptions.
The caller to these methods has to handle the exception using a try-catch block.
User-defined exception:
A user-defined exception in Java, also known as a custom exception, is a class created by a programmer to
handle specific error conditions or exceptional situations within their application that are not adequately
covered by Java's built-in exception classes.

Conclusion: Thus we have successfully studied & implemented exception.

LOs Achieved: LO2

POs Achieved: PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9, PO11

PSOs Achieved: PSO1, PSO2


Experiment No. 6

Aim: Implement login webpage in JSP that makes validation through Database using JDBC and call the servlets for
various operations.

Theory:
JDBC refers to the Java Database Connectivity. It provides java API that allows Java programs to access database
management systems (relational database). The JDBC API consists of a set of interfaces and classes which enables java
programs to execute SQL statements. Interfaces and classes in JDBC API are written in java.
JDBC core components:
The JDBC API consists of the following core components:
1. JDBC Drivers
2. Connections
3. Statements
4. ResultSets
1. JDBC Drivers:
JDBC driver is a collection of classes which implements interfaces defined in the JDBC API for opening database
connections, interacting with database and closing database connections.
2. Connections:
Before performing any database operation via JDBC, we have to open a database connection. To open a database
connection we can call getConnection() method of DriverManager class.
Syntax:
Connection connection = DriverManager.getConnection(url, user, password)
3. Statements:
The JDBC statements are used to execute the SQL or PL/SQL queries against the database. We need a statement for
every single query. JDBC API defines the Statement, CallableStatement, and PreparedStatement types of statements.
4. ResultSets:
A query returns the data in the form of ResultSet. To read the query result date ResultSet provides a cursor that points
to the current row in the result set.
Servlets provide a component-based, platform-independent method for building Webbased applications, without the
performance limitations of CGI programs. Servlets have access to the entire family of Java APIs, including the JDBC API
to access enterprise databases.
A servlet life cycle can be defined as the entire process from its creation till the destruction. The following are the
paths followed by a servlet.
 The servlet is initialized by calling the init() method.
 The servlet calls service() method to process a client's request.
 The servlet is terminated by calling the destroy() method.
 Finally, servlet is garbage collected by the garbage collector of the JVM.

Conclusion: Thus we have successfully studied & Implemented login webpage in JSP that makes validation through
Database using JDBC and call the servlets for various operations

LOs Achieved: LO3

POs Achieved: PO1 PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9, PO11

PSOs Achieved: PSO1, PSO2


Experiment No. 7

Aim: Implement a website using HTML CSS and JavaScript (create your own profile page)

Theory:
HTML stands for Hyper Text Markup Language. It is the standard markup language for creating Web pages.
It describes the structure of a Web page. It consists of a series of elements. HTML elements tell the browser
how to display the content & label pieces of content such as "this is a heading", "this is a paragraph", "this is
a link", etc.

CSS stands for Cascading Style Sheets. It describes how HTML elements are to be displayed on screen, paper, or in
other media. It saves a lot of work. It can control the layout of multiple web pages all at once.External stylesheets are
stored in CSS files.

Steps to Create Static Pages:


Step 1: Firstly, we will create a folder with the project name and create the HTML (e.g, index.html), CSS (e.g, style.css),
JavaScript files, Images folder, and a separate file for the responsive CSS if required.
Step 2: By using various HTML tags like section, header, meta, title, head, div, I, mg, etc to structure the web page and
includes a header, navigation bar, main content area, and a script tag for our JavaScript file.
Step 3: Add some Style using CSS to the HTML code to make our frontend look good. We'll choose colors and layouts
that look modern and inviting. Add style mainly to the image and beautify the header.
Step 4: Add the JavaScript function, like updating the content based on what the user clicks.
Step 5: You can create a navigation system that dynamically loads content based on user interactions.

Conclusion: Thus we have successfully studied & Implemented website using HTML CSS and JavaScript.

LOs Achieved: LO3

POs Achieved: PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9, PO11

PSOs Achieved: PSO1, PSO2


Experiment No. 8

Aim: Implement a program using Java Script to validate the email address entered by the user (check the presence of
“@” & “.” character. If this character is missing, the script should display an alert box reporting the error and ask the
user to re-enter it again).
Theory:
JavaScript is the programming language of the web. It can update and change both HTML and CSS. It can calculate,
manipulate and validate data.
Steps to Create Static Pages:
Step 1: Firstly, we will create a folder with the project name and create the HTML (e.g, index.html), CSS (e.g, style.css),
JavaScript files, Images folder, and a separate file for the responsive CSS if required.
Step 2: By using various HTML tags like section, header, meta, title, head, div, I, mg, etc to structure the web page and
includes a header, navigation bar, main content area, and a script tag for our JavaScript file.
Step 3: Add some Style using CSS to the HTML code to make our frontend look good. We'll choose colors and layouts
that look modern and inviting. Add style mainly to the image and beautify the header.
Step 4: Add the JavaScript function, like updating the content based on what the user clicks.
Step 5: You can create a navigation system that dynamically loads content based on user interactions.

Conclusion: Thus we have successfully studied & implemented a program using Java Script to validate the email
address entered by the user.

LOs Achieved: LO4

POs Achieved: PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9, PO11

PSOs Achieved: PSO1, PSO2


Experiment No. 9

Aim: Implement a program based on Document Object Model to change the background color of the web page
automatically after every 5 seconds.

Theory:
The Document Object Model (DOM) is a programming interface for web documents. It represents the page so that
programs can change the document structure, style, and content. The DOM represents the document as nodes and
objects; that way, programming languages can interact with the page.

Conclusion: Thus we have successfully studied & implemented a program based on Document Object Model to
change the background color of the web page automatically after every 5 seconds.

LOs Achieved: LO4

POs Achieved: PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9, PO11

PSOs Achieved: PSO1, PSO2


Experiment No. 10

Aim: Implement a program for making use of React Hooks that displays four buttons namely, “Red”, “Blue”, “Green”,
“Yellow”. On clicking any of these buttons, the code displays the message that you have selected that particular color.

Theory:
React is a front-end JavaScript library. It was developed by the Facebook Software Engineer Jordan Walke. It is also
known as React.js or ReactJS. It is a tool for building UI components.

Conclusion: Thus we have successfully studied & implemented a program for making use of React Hooks.

LOs Achieved: LO5

POs Achieved: PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9, PO11

PSOs Achieved: PSO1, PSO2


Experiment No. 11

Aim: Implement a program to create a Monolithic Application using SpringBoot.

Theory:
Spring Boot is an open-source Java framework used to create a Micro Service. Spring boot is developed by Pivotal
Team, and it provides a faster way to set up and an easier, configure, and run both simple and web-based applications.
It is a combination of Spring Framework and Embedded Servers. The main goal of Spring Boot is to reduce
development, unit test, and integration test time and in Spring Boot, there is no requirement for XML configuration.

Conclusion: Thus we have successfully studied & implemented a program to create a Monolithic Application using
SpringBoot.

LOs Achieved: LO5

POs Achieved: PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9, PO11

PSOs Achieved: PSO1, PSO2


Experiment No. 12

Aim: Mini Project.

Theory:
Implement any real life application. (Report Format will be provided separetly)

LOs Achieved: LO1, LO2, LO3, LO4, LO5, LO6

POs Achieved: PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9, PO11

PSOs Achieved: PSO1, PSO2


Experiment No. 13

Aim: Implement a program on collections.

Theory:
A collection in Java is a group of individual objects that are treated as a single unit. In Java, a separate framework
named the "Collection Framework" was defined in JDK 1.2, which contains all the Java Collection Classes and
interfaces.
In Java, the Collection interface (java.util.Collection) and Map interface (java.util.Map) are the two main “root”
interfaces of Java collection classes.

LOs Achieved: LO1, LO2, LO3, LO4, LO5, LO6

POs Achieved: PO1, PO2, PO3, PO4, PO5, PO7, PO8, PO9, PO11

PSOs Achieved: PSO1, PSO2

You might also like